I see a lot of controversial documentation about using Storage with Cloud Functions. I really don't understand which documentation I should to use. Anyway I think I've tried all of them and nothing is working. Please help me. For example: I'm trying to use this docs: https://firebase.google.com/docs/storage/admin/start
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
const database = admin.database();
var bucket = admin.storage().bucket("my-custom-bucket");
I have the error
Unhandled error TypeError: storage.bucket is not a function
If I see this docs: https://firebase.google.com/docs/storage/extend-with-functions.
What's that?
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
const database = admin.database();
const gcs = require('@google-cloud/storage')(); //!!! - is it mistype?
const spawn = require('child-process-promise').spawn;
const path = require('path');
const os = require('os');
const fs = require('fs');
const bucket = gcs.bucket('fileBucket');
TypeError: require(...) is not a function
but anyway even if it is mistype it will be next error:
TypeError: gcs.bucket is not a function
And yes I did install:
npm install --save child-process-promise
npm install --save @google-cloud/storage
Does anybody know how to use it? Or where is correct documentation?