根据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',
},
});
Run Code Online (Sandbox Code Playgroud)
我在我的服务器端代码中使用 Firebase Admin SDK (Nodejs),客户端以我作为文件对象获取的表单数据发送文件。当函数只接受通向文件路径的文件名时,我如何上传它。
我希望能够做这样的事情
app.use(req: Request, res: Response) {
const file = req.file;
// upload file to firebase storage …
Run Code Online (Sandbox Code Playgroud) node.js express google-cloud-storage firebase firebase-admin