Skip to content

Commit 5737956

Browse files
committed
storage
1 parent df92df5 commit 5737956

File tree

5 files changed

+1389
-1
lines changed

5 files changed

+1389
-1
lines changed

lerna.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"functions/stackdriver-logging",
1717
"functions/firestore-export",
1818
"management",
19-
"messaging"
19+
"messaging",
20+
"storage"
2021
],
2122
"version": "1.0.0"
2223
}

storage/index.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const admin = require('firebase-admin');
2+
3+
function initDefaultBucket() {
4+
// [START storage_init_default_bucket]
5+
const admin = require("firebase-admin");
6+
7+
const serviceAccount = require("./path/to/serviceAccountKey.json");
8+
9+
admin.initializeApp({
10+
credential: admin.credential.cert(serviceAccount),
11+
storageBucket: "<BUCKET_NAME>.appspot.com"
12+
});
13+
14+
const bucket = admin.storage().bucket();
15+
16+
// 'bucket' is an object defined in the @google-cloud/storage library.
17+
// See https://googlecloudplatform.github.io/google-cloud-node/#/docs/storage/latest/storage/bucket
18+
// for more details.
19+
// [END storage_init_default_bucket]
20+
}
21+
22+
function customBucket() {
23+
// [START storage_custom_bucket]
24+
const bucket = admin.storage().bucket("my-custom-bucket");
25+
// [END storage_custom_bucket]
26+
}
27+
28+
function customApp() {
29+
const customApp = admin.initializeApp({
30+
// ...
31+
}, "custom");
32+
33+
// [START storage_custom_app]
34+
const bucket = customApp.storage().bucket();
35+
// [END storage_custom_app]
36+
}

0 commit comments

Comments
 (0)