【发布时间】:2019-07-12 01:30:38
【问题描述】:
我在做:
const fileId = uuidv4()
console.log(process.env.GOOGLE_PRIVATE_KEY)
const storage = new GoogleCloudStorage({
projectId: process.env.GOOGLE_RAW_AUDIO_BUCKET,
credentials: {
client_email: process.env.GOOGLE_CLIENT_EMAIL,
private_key: process.env.GOOGLE_PRIVATE_KEY.replace(/\\n/g, '\n')
}
});
const bucket = storage.bucket(process.env.GOOGLE_RAW_AUDIO_BUCKET);
const blob = bucket.file(fileId + 'mp3');
const blobStream = blob.createWriteStream()
console.log(req.file)
// var readableStream = fs.createReadStream(req.file.path);
fs.createReadStream(req.file.buffer).pipe(blobStream)
但我得到一个错误:
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string or Uint8Array without null bytes. Received <Buffer ff f3 38 c4 00 00 00 03 48 00 00 00 00 4c 41 4d 45 33 2e 39 39 2e 35 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 ..
使用multer 和express。但我不知道如何从 multer 流式传输到 GCS。任何提示将不胜感激?
【问题讨论】:
标签: javascript node.js express google-cloud-storage multer