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