Firebase-admin-node: Uploading Files to Firebase using Admin SDK (Nodejs)

Created on 11 Mar 2019  路  2Comments  路  Source: firebase/firebase-admin-node

According to the Docs, I have to pass the filename to the function in order to upload a file.

// Uploads a local file to the bucket
await storage.bucket(bucketName).upload(filename, {
  // Support for HTTP requests made with `Accept-Encoding: gzip`
  gzip: true,
  metadata: {
    // Enable long-lived HTTP caching headers
    // Use only if the contents of the file will never change
    // (If the contents will change, use cacheControl: 'no-cache')
    cacheControl: 'public, max-age=31536000',
  },
});

I am using Firebase Admin SDK (Nodejs) in my server side code and clients send file in form-data which i get as File Objects. How then do i upload this when the function accepts only filename leading to filepath.

I want to be able to do something like this

app.use(req: Request, res: Response) {
 const file = req.file;
// upload file to firebase storage using admin sdk
}

needs-triage

All 2 comments

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

Please use Stackoverflow for usage help questions such as this one.

Was this page helpful?
0 / 5 - 0 ratings