nathanpeck / s3-upload-stream

A Node.js module for streaming data to Amazon S3 via the multipart upload API
MIT License
347 stars 46 forks source link

Resuming in a later session results in corrupted uploads #45

Open mikew opened 7 years ago

mikew commented 7 years ago

How is one supposed to track parts as they are uploaded? Our app needs to upload giant files, and we need to handle poor internet connections. So there's not always a chance that the upload will ever send out a pause event.

Currently we are tracking parts from the part event and adding them to an array. When I use the UploadId and Parts from a previous session, s3-upload-stream always starts from the beginning and ends up uploading too much, corrupting the file.

Here's how we're calling s3-upload-stream

const destinationDetails = {
  // ...
}

const sessionDetails = {
  "UploadId": "SECRET_UPLOAD_ID",
  "Parts": [
    {
      "ETag": "\"ee72b288175a979f6475b7241dcb9913\"",
      "PartNumber": 1
    },
    {
      "ETag": "\"e33260ba6180f1294592f25985c0109e\"",
      "PartNumber": 2
    }
  ]
}

const uploader = s3Stream.upload(destinationDetails, sessionDetails)

uploader.on('part', details => {
  console.log(details)
})

And if we see what the part event logs:


{
  "ETag": "\"ee72b288175a979f6475b7241dcb9913\"",
  "PartNumber": 3
}

It's the exact same ETag we passed in via sessionDetails, and it gets uploaded as another part, which corrupts the file.

Rambarani commented 5 years ago

Did you find answer ?? . i am facing the same issue , can't get answer , can you please help me ??