Last active
          February 20, 2019 12:34 
        
      - 
      
- 
        Save ponnamkarthik/50f9f6629897a9bf79d579faf1ef44e3 to your computer and use it in GitHub Desktop. 
    Firebase Storage generate Signed Url
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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