1
我现在用的是NPM documentation的图像上传到谷歌云存储属性图像使用谷歌云存储
app.post('/test', upload.single('image'), function (req, res, next) {
});
let bucket = gcs.bucket('bucket-name');
bucket.upload(req.file.path, function(err, file) {
if (err) {
throw new Error(err);
}
console.log(file);
});
console.log(req.file);
// req.body will hold the text fields, if there were any
})
存储有什么方法可以让我指定我的文件自定义名称和文件类型上传?在我的情况下,它应该是一个图像。
谢谢!与创建写入流而不是使用上传方法相比,是否有任何优势? – user3642173
'bucket.upload'只是一个方便的方法,它会执行'createWriteStream' [检查文档API](https://googlecloudplatform.github.io/google-cloud-node/#/docs/storage/0.5.0/ storage/file?method = createWriteStream) – Erevald
明白了 - 谢谢 – user3642173