-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Changing the upload id of an uppy file upload #1399
Comments
It's best not to muck with the ID because Uppy uses it internally for bookkeeping. The progress object error probably happens because Uppy tries to access a file by the ID it knew previously. Uppy's internal storage uses an immutable style, so file objects can be switched out at any time. We tend to not store references to file objects directly, the IDs are the only consistent thing :) To get an identifieer suitable for use on the backend, I'd recommend using a properly unique one and sending it as metadata (or generating it on the backend in the first place if possible). With a package like https://www.npmjs.com/package/uuid, you can do: const generateUuid = require('uuid/v4')
uppy.on('file-added', (file) => {
uppy.setFileMeta(file.id, { id: generateUuid() })
}) |
Thanks for your quick reply. The problem I am facing is that I am getting duplicate keys from id's generated by Uppy. When I upload the same file, it creates a file name with the same Uppy upload id. Ideally I'd like to have this id different. Any suggestions? |
It’s been discussed and asked for in a few issues, and there’s a PR: #1334. But we haven’t landed on a good solution yet, because the proposed ones might break some functionality for resumable uploads and such. |
Is the problem with IDs clashing on the frontend_, or on the backend? I would recommend against using Uppy-generated IDs for file names. |
I went around and fixed this by passing date metadata through on a new file upload and then appending that to the Uppy-generated ID, then mapping that back after I have processed that file on the server.
So the problem is definitely on the front end though. We were using the Uppy-generated ID for an array key. Though perhaps a bigger problem, is that the Uppy Tus options are not working altogether. I am passing in the following options and the only one that seems to work is the endpoint. Nothing else is firing. RemoveFingerPrintOnSuccess is very important, though it isn't doing anything. The fingerprint seems to be only removed after I refresh the page? OnSuccess function or OnError function never called.
Not sure why any of the Tus options are not working except the endpoint? |
Hi there, closing this, as we're continuing the remaining issue in #1327. Feel free to re-open if you disagree! |
I would like to change the uppy file id before it is uploaded to the server.
I have tried the following:
I am basically trying to add the date before the id before I upload it. Any suggestions greatly appreciated. The error when I get this code, is an key value that sits within the progress object is undefined.
The text was updated successfully, but these errors were encountered: