feat: return object id in TUS upload completion response header#998
Open
oniani1 wants to merge 2 commits intosupabase:masterfrom
Open
feat: return object id in TUS upload completion response header#998oniani1 wants to merge 2 commits intosupabase:masterfrom
oniani1 wants to merge 2 commits intosupabase:masterfrom
Conversation
Coverage Report for CI Build 24208084802Coverage decreased (-0.001%) to 80.842%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #647
Summary
After a TUS resumable upload completes, there's currently no way to get the
object_idof the uploaded file without making a follow-up.list()call. TheonSuccesscallback fromtus-js-clientonly gets the upload URL, not the object ID.The standard
POST /objectendpoint already returns the ID in the JSON body ({ Id, Key }). For TUS, since the response format is governed by the protocol, a response header is the natural fit -- same approach @fenos suggested in #647.This captures the return value of
completeUpload()in theonUploadFinishlifecycle hook and includes the object's UUID in a newx-supabase-idresponse header. The@tus/serverlibrary already supports custom headers -- bothPatchHandlerandPostHandlermerge them into the outgoing response.Changes
src/http/routes/tus/lifecycle.ts-- capturecompleteUpload()result, addx-supabase-idheadersrc/test/tus.test.ts-- new test verifying the header is present, is a valid UUID, and matches the database recordTest plan
x-supabase-idheader with valid UUID matching DB record