TTLabs / EvaporateJS

Javascript library for browser to S3 multipart resumable uploads
1.82k stars 207 forks source link

restart upload different destination #461

Open Djolivald opened 4 years ago

Djolivald commented 4 years ago

Hi, I am having an issue with upload restart. When cancelling an upload Evaporate save the file/md5 in cache. My issue is that if the user decides to reupload the same file it will restart the old upload regardless of the new upload destination.

I think the upload destination should be matching (along with the md5) for a file to continue upload. I end up in situations where I detect the upload as being dead/cancelled server side, deleting the upload and parts in S3 and creating a new record for the new upload, but Evaporate still uploads to the old location.

Alternatively, is it possible to prevent the upload restart mechanism altogether? I prefer to lose the feature to allow to restart uploads over having users uploading to the wrong destination.

Thanks!

jakubzitny commented 4 years ago

Hi @Djolivald, can you please create a minimal reproduction repo where this is happening? We're using Evaporate and probably had very similar cases but the problem was not happening.

Djolivald commented 4 years ago

Sure thing, if you use the example from the repo set it up with your AWS creds/bucket/signing url.

Uploading a file named large_test.mp4: The console outputs started uploads/large_test.mp495.45298906767776 This entry in awsUploads in application storage

{
   "large_test.mp4-video/mp4-2020-10-25T19:25:28.517Z-4489775427":{
      "awsKey":"large_test.mp495.45298906767776",
      "bucket":"uploads",
      "uploadId":"....",
      "fileSize":4489775427,
      "fileType":"video/mp4",
      "lastModifiedDate":"2020-10-25T19:25:28.517Z",
      "partSize":6291456,
      "signParams":{

      },
      "createdAt":"2020-11-02T16:07:59.254Z",
      "firstMd5Digest":"rq7kVMTInphzU4zw4F8WZw=="
   }
}

Then cancel the upload, and create an new one with the same file. The console outputs started uploads/large_test.mp432.831321426160606 There is no new entry in the application storage (and the old one did not change) and the network request are going to https://bucket.s3.amazonaws.com/uploads/large_test.mp495.45298906767776?uploadId=... Note the upload request is done on the first upload location

Djolivald commented 4 years ago

Hey @jakubzitny Just wanted to check whether you have a way to prevent this behaviour? My temporary solution is to wipe the application storage before each upload... Not very sexy