0
更新Google云端存储分区中的图片时,即使图片更新成功,网址也会为旧版本提供一段时间(几分钟,例如5分钟左右)。来自Google云端存储分区的图片不会立即更新
链接我们使用的模样:
https://storage.googleapis.com/<bucket-name>/path/to/images/1.jpg
哪些更新的图像的代码的相关部分是:
var storageFile = bucket.file(imageToUpdatePath);
var storageFileStream = storageFile.createWriteStream({
metadata: {
contentType: req.file.mimetype
}
});
storageFileStream.on('error', function(err) {
...
});
storageFileStream.on('finish', function() {
// cloudFile.makePublic after the upload has finished, because otherwise the file is only accessible to the owner:
storageFile.makePublic(function(err, data) {
//if(err)
//console.log(err);
if (err) {
return res.render("error", {
err: err
});
}
...
});
});
fs.createReadStream(filePath).pipe(storageFileStream);
它看起来像在谷歌云侧的缓存问题。如何解决它?更新后如何在请求的网址获取更新后的图片?
在Google云端管理员中,新图片确实显示正确。
确实确定了它!非常感谢。 '':-) –