javascript - 使用 file.save() 将图像上传到 Google Cloud Storage。一切似乎都成功,但图像不起作用
问题描述
我正在尝试将图像上传到 Google Cloud Storage 以在网站上使用。我正在从 apiflash 截屏并接收图像数据。
使用图像数据,然后我尝试使用 file.save() 将其保存到 Google Cloud
除了图像未显示之外,一切都在进行中。
这是 Gcloud 存储仪表板中的图像。
它正在抛出的错误消息
这是上传的代码。我错过了什么吗?它成功并且上传工作,只是没有图像。返回的图像是 jpeg 类型,我尝试过使用 .jpg 并且还接收到 png,但这会产生相同的错误。
响应正文只是图像数据,没有别的......很多......
0\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05(\x00\x01J\x00\x00R�\x00\x14�\x00\x05+��"
request(options, function (error, response) {
if (error) throw new Error(error);
const content = response.body;
const file = bucket.file(`${gameid}.jpeg`);
file.save(
content,
{
resumable: false,
public: true,
contentType: response.headers['content-type'],
},
(err) => {
if (!err) {
console.log('success');
} else {
console.log('ERROR', err);
}
}
);
});
任何意见,将不胜感激。
谢谢
解决方案
推荐阅读
- python - Python 创建 csv 但它是空的
- r - 空格改变 str_match 结果的顺序
- mysql - 如何在mysql中获取X个唯一记录
- pdf - 将pdf转换为图像的最佳技术
- react-native - 反应导航打开openDrawer()不起作用
- c# - Selenium IJavaScriptExecutor 不工作
- git - heroku git:clone -a 有什么区别
和 git 克隆 ? - python-3.x - python中的函数以接受本地文件夹
- elasticsearch - 在 Elasticsearch-dsl 中使用多个值匹配查询
- r - 交错的数据创建额外的行(例如时间变量)