【发布时间】:2017-05-06 11:38:48
【问题描述】:
通过 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 存储控制台中查看文件时,文件类型设置为默认应用程序/八位字节流。检查图像的元数据时,它会在“其他元数据”中显示 contentType: 'img/jpeg'。
这里出了什么问题?
【问题讨论】:
标签: node.js firebase firebase-storage google-cloud-functions