-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Returning a body in onUploadFinish is not having any effect in the response #714
Comments
We have an e2e test confirming this works: tus-node-server/packages/server/test/Server.test.ts Lines 607 to 639 in 7db2f17
Are you on the latest version? |
Are you sure this is a response to a PATCH request? Looks like a HEAD response to me (due to the Upload-Metadata header being present). |
Yes, I'm on latest versions:
|
Could it be that the use of |
If that's the case, the logs should also contain a notice about this:
|
Uhm no, that's not it. The following code has the same issue. onUploadFinish: async (req, res, upload) => {
return {
res,
status_code: 204,
body: `https://${S3_ENDPOINT}/${S3_BUCKET}/${upload.id}`
}
} |
Ok, so I think I've found the issue. For some reason, when I upload a file I've already uploaded, the Is there some kind of cache or something that ignores re-uploads? My namingFunction is generating a new id for each file so I was assuming uploading the same file multiple times, would result in multiple files. At least, that's how it works when using Transloadit. namingFunction(_req, metadata) {
invariant(metadata?.filename, "filename is required")
invariant(metadata?.userId, "userId is required")
const id = nanoid()
const userId = metadata.userId;
const filename = metadata.filename;
const extension = filename.split('.').pop();
return `${userId}/${id}.${extension}`
}, |
tus-js-client and Uppy stores information about started uploads in localStorage to allow users to resume uploads. This also includes completed uploads, meaning that when trying to upload the same file again, tus-js-client recognizes that it transferred this file before, checks with the server whether the file still exists and then does not upload the file again. You can enable tus-js-client's |
I understand that, but quoting you "and then does not upload the file again" so then why does the |
I answered that question in https://community.transloadit.com/t/allow-duplicate-files-whist-keeping-the-resumable-feature/17086/6:
|
Closing this as it's not an issue but how resumable uploads work. If you want to upload duplicates files, you can set removeFingerprintOnSuccess in tus-js-client or Uppy. |
Initial checklist
Steps to reproduce
Context: https://community.transloadit.com/t/how-to-customize-the-url-reported-back-to-the-client-in-tus-server/17457/7
Expected behavior
The response contains the right 204 status code and body.
Actual behavior
No matter what's returned on the
onUploadFinish
, the response is always 200 with an empty body.Example response with above code. Should be 204 and body should not be empty.
The text was updated successfully, but these errors were encountered: