Skip to content

Instantly share code, notes, and snippets.

@ponnamkarthik
Last active February 20, 2019 12:34
Show Gist options
  • Save ponnamkarthik/50f9f6629897a9bf79d579faf1ef44e3 to your computer and use it in GitHub Desktop.
Save ponnamkarthik/50f9f6629897a9bf79d579faf1ef44e3 to your computer and use it in GitHub Desktop.
Firebase Storage generate Signed Url
var serviceAccount = require("./service/cred.json");
// admin.initializeApp(functions.config().firebase);
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
});
const { Storage } = require('@google-cloud/storage');
const storage = new Storage();
const options = {
action: 'read',
expires: Date.now() + 1000 * 60 * 60, // one hour
};
// Get a signed URL for the file
storage
.bucket(bucket_videos)
.file('videos/' + videoId + '/' + videoId + "_360.mp4")
.getSignedUrl(options)
.then(singnedUrl => {
console.log(singnedUrl[0])
return null;
})
.catch(error => {
console.log(error);
console.log("Error");
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment