从Firebasefunction(节点)上传时,Firebase存储文件types未设置
通过Firebase函数(节点)将转换后的图像(.jpg)上传到谷歌存储时,我在元数据选项中设置了contentType。
return bucket.file(filePath).download({destination: tempFilePath}) .then(() => { console.log('Image downloaded locally to', tempFilePath); // Generate a thumbnail using ImageMagick. return spawn('convert', [tempFilePath, '-thumbnail', '200x200>', tempFilePath]) }) .then(() => { console.log('Thumbnail created at', tempFilePath); // Add a 'thumb_' prefix to thumbnails file name. That's where we'll upload the thumbnail. const thumbFilePath = filePath.replace(/(\/)?([^\/]*)$/, `$1thumb_$2`); // Uploading the thumbnail. return bucket.upload(tempFilePath, { destination: thumbFilePath, metadata: { metadata: { contentType: 'image/jpeg', firebaseStorageDownloadTokens: uuid } } });
当我在Firebase存储控制台中查看文件时,文件types将被设置为默认应用程序/八位字节stream。 当检查图像的元数据时,它会在“其他元数据”中显示contentType:'img / jpeg'。
这里怎么了?
我看到你正在使用'元数据'两次。 试试这个:
return bucket.upload(tempFilePath, { destination: thumbFilePath, metadata: { contentType: 'image/jpeg', firebaseStorageDownloadTokens: uuid } });
- Firebase在用户login时创build条目
- 如何检查https云function的身份validation?
- 错误:加载firebase.json时出现错误:未安装Bolt,运行npm install -g firebase-bolt
- Firebase并发读取/写入
- firebase是否为每个admin.auth()。verifyIdToken(idToken)发出networking请求?
- 使用Firebasefunction更新存储更改上的Firebase数据库
- Firebase的云端function – 未configuration帐单帐户
- Firebasepipe理员身份validation令牌被吊销
- 使用Google API的Firebase – 需要帐单和/或身份validation