Skip to content

Instantly share code, notes, and snippets.

@matthewharwood
Created May 13, 2019 01:20
Show Gist options
  • Save matthewharwood/3f2bee82e64999bfd4487e1c1a27ba1c to your computer and use it in GitHub Desktop.
Save matthewharwood/3f2bee82e64999bfd4487e1c1a27ba1c to your computer and use it in GitHub Desktop.
Small script to allow to add files to a gcp bucket
const admin = require("firebase-admin");
const globby = require('globby');
const serviceAccount = require("../../cert.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
storageBucket: "" // e.g. genesis-morningharwood.appspot.com
});
var bucket = admin.storage().bucket();
(async () => {
const paths = await globby(['../../www/mh/build'], {
expandDirectories: {
extensions: ['png', 'jpg', 'gif']
}
});
paths.forEach(p => bucket.upload(p));
console.log('ALL FINISHED');
})();