Google Cloud Storage“上传请求无效”错误。错误的请求

San*_*ria 7 node.js google-cloud-storage google-cloud-platform

我已经从我的 Node JS 服务器将文件上传到谷歌云存储很长一段时间了。但有时会上传失败。返回的错误信息类似于:

{
    reason:"badRequest", 
    code: 400,
    message: "Invalid upload request"
}
Run Code Online (Sandbox Code Playgroud)

它是随机发生的,意味着大约 25-30 天发生一次,持续一段时间,然后自动解决。这有点奇怪,搜索它没有给出任何解决方案或原因。

上传请求是针对具有完全相同数据的两个文件并行发送的。一个上传成功,另一个失败。

使用的代码:

const file = bucket.file(`data/${id}/${version}/abc.json`);
const dataBuffer = Buffer.from(JSON.stringify(dataToUpload));
file.save(dataBuffer, storageConfig)
    .then(() => callback(null, true))
    .catch(err => callback(err, null));
Run Code Online (Sandbox Code Playgroud)

其中 storageConfig 是

{
    "contentType": "application/json",
    "cacheControl": "public, max-age=600, s-maxage=3, no-transform"
}
Run Code Online (Sandbox Code Playgroud)

存储的第二个文件名是

const file = bucket.file(`data/${id}/latest/abc.json`);
Run Code Online (Sandbox Code Playgroud)

我找不到任何原因,也无法处理。它使我的相关系统崩溃,因为它们需要第二个文件。

Saš*_*jak 8

resumable: false上传选项中的设置为我解决了同样的错误。例如 :bucket.upload(pathToUpload, { destination: bucketPath, resumable: false })