【发布时间】:2019-08-02 07:51:12
【问题描述】:
根据Docs,我必须将文件名传递给函数才能上传文件。
// 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',
},
});
我在我的服务器端代码中使用 Firebase Admin SDK (Nodejs),客户端以我作为文件对象获得的表单数据发送文件。当函数只接受导致文件路径的文件名时,我该如何上传。
我希望能够做这样的事情
app.use(req: Request, res: Response) {
const file = req.file;
// upload file to firebase storage using admin sdk
}
【问题讨论】:
标签: node.js firebase express google-cloud-storage firebase-admin