Can't download file using google cloud storage and Cloud Functions for Firebase -


i having opposite issue: issues deleting image using cloud functions firebase , @google-cloud/storage

(for record, have tried things suggested there).

basically have known file path, cloud function triggered database event.

i can initialise bucket, file name, when try , download api error: not found.

here code:

module.exports = (orgid, reportid) => {   const bucket = gcs.bucket("my_project.appspot.com");    const filepath = `/safety_hotline/${orgid}/${reportid}`;   const file = bucket.file(filepath);    // name shown correctly in console   console.log(file.name);    const templocalfile = path.join(os.tmpdir(), filepath);   const templocaldir = path.dirname(templocalfile);    return mkdirp(templocaldir)     .then(() => {       // download file bucket.       return file.download({ destination: templocalfile });     })     .then(() => {       console.log("file downloaded succesfully");     })     .catch(err => {       console.log(err);     }); } 

enter image description here

you can see console log of file name, don't understand why can't download it? advice amazing, thanks!

edit: edited code bit clarity

i see have line:

  const filepath = `/safety_hotline/${orgid}/${reportid}`; 

i guessing may have named objects pattern safety_hotline/org/report, written above first character of object name slash. that's legal object name it's unintentional. try removing slash?


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -