tus / tusd

Reference server implementation in Go of tus: the open protocol for resumable file uploads
https://tus.github.io/tusd
MIT License
2.92k stars 465 forks source link

How to clean up partial upload chunks after final upload success? #1121

Closed loren-m-crawford closed 2 months ago

loren-m-crawford commented 2 months ago

Question Hey folks! I'm having a bit of a difficult time understanding how best to clean up partial upload chunks from our datastore after we've successfully uploaded the final concatenated upload. Currently, our partial uploads and final uploads are getting stored to the same bucket and aren't tagged differently or getting cleaned up. Do we need to add something different in our config? Do we need to have a different ConcaterDataStore for partials to get cleaned up properly?

Setup details Please provide following details, if applicable to your situation:

loren-m-crawford commented 2 months ago

I think I understand what I need to do. I believe it looks like I need to setup another S3Store for the ConcaterStore on the composer with a separate bucket path with a different delete policy.

Acconut commented 2 months ago

With tus, a partial upload could be reused for a different concatenation in theory, so they are not cleaned up automatically. When we used S3 as our backend in production, we had a lifetime policy which removed all old uploads, which included partial and final uploads. Depending on your use case, it might be fine to use a similar approach and handle the lifetime of partial uploads just like any other upload.

Alternatively, you could use a post-finish hook to manually delete the partial uploads that were used for concatenation. The hook request includes information about whether the upload is a final or partial part and what partial uploads where used (see IsFinal, IsPartial, and PartialUploads).

I hope this helps.