我试图在节点 js 中将大文件上传到 s3, 所有部分都已上传,但在 MultipartUpload 中,当我尝试合并所有部分时出现错误:InvalidPart: null 这是相关代码:
let partNumber=1;
let numPartsUploaded=0;
readStream.on("data", (chunk)=>{
const partParams={
Bucket="myBucketName",
Key="name",
PartNumber:partNumber,
UploadId:uploadId,
Body:chunk
};
s3.uploadPart(partParams, (err,data)=>{
if(err){
console.log("Error upload part", err)
return;}
consol.log(`part ${partNumber} uploaded successfully`)
parts.push({ETag:data.ETag,PartNumber:partNumber});
partNumber++;
numPartsUploaded++;
if(numPartsUploaded===Math.ceil(readStream.bytesRead/partSize)){
s3.completeMultipartUpload({
Bucket="myBucketName",
Key="name",
UploadId:uploadId,
MultipartUpload:{Parts:parts},},(err,data)=>{
if(err){
consol.log("error: ",err)
return;}
consol.log("file uploaded successfully")
});}});});
我也没有看到 s3 中的部分,但是也许在上传完成之前我看不到它?
感谢任何回答
我记录了零件数组,没有 null 看起来不错