Firebase cloud storage, TypeError: firebase.storage is not a function

Viewed 874

I try to run this code.

const firebase = require('firebase');
const gcs = require('@google-cloud/storage');


const apiKey = '<KEY>';
const projectID = '<ID>';
const dbName = 'db';
const bucketName = '<BUCKET>.appspot.com';
const keyFile = './firebase.json';

const config = {
    apiKey: apiKey,
    authDomain: `${projectID}.firebaseapp.com`,
    databaseURL: `https://${dbName}.firebaseio.com`,
    storageBucket: 'test-55625.appspot.com'
};

const gcsConfig = {
    projectId: 'grape-spaceship-123',
    keyFilename: keyFile
};

const app = firebase.initializeApp(config);

So, I wanna use a a cloud storage, but I can't. I have tried next tips:

firebase.storage()
app.storage()
firebase.app().storage()

Or anything like this. So I tried to use this library too
const gcs = require('@google-cloud/storage'); But I can just download an empty file and can't upload file to storage. May be docs is deprecaetd, may be I can't understand something, or I use wrong keyfile! Thanks for you attention.

0 Answers
Related