dash-uploader icon indicating copy to clipboard operation
dash-uploader copied to clipboard

upload_id not updated when new component created

Open cogency opened this issue 4 years ago • 4 comments

Little bug I found: 'upload_id' appears to be "frozen" to the first upload component that is created. So if it is created with upload_id=None (it will default to the internal session id) but then if a new layout is generated with the same IDs, but a new/different upload_id, the original upload_id is still used. Interestingly, the callbacks get the "new" upload_id, even though the files get created in the "old" upload_id folder.

I have confirmed, that if the upload ID is cycled too, then it works as expected, so React is caching the original component upload_id somewhere.

(In my use case, I am trying to cycle the upload_id for the upload component whenever a drawer is opened and a new form is generated so that the associated files can be easily separated from older stuff in the folder. The callback does not adequately report on multiple file selection - only a single file is returned, so the only way to find out is to list the files in the temp folder - which now may not be unique. I guess the temporary work-around is to scrub the session folder.)

Anyway, awesome project - thanks for sharing!

cogency avatar Jun 26 '21 01:06 cogency

I think I am experiencing the same problem. My use case is to allow sequential uploads from the same tab. I need there to be just one file in each unique folder.

A new du.Upload() is created with a new upload_id each time the user presses 'cancel' or 'save'. The layout "id" is the same. The reported "filenames[0]" has the correct upload_id folder. But the file is saved to the original upload_id 's folder.

I agree that react appears to be caching the initial upload_id and uses that to store the file.

The workaround seems awful: store the upload_id for the session, then manually clean out the folder from other callback functions.

Any chance you can address this soon?

ms-ai avatar Jul 23 '21 02:07 ms-ai

Thanks for the report! I have limited time on this project, but I'm happy to accept pull reqests targeting on this.

fohrloop avatar Aug 10 '21 10:08 fohrloop

I think I am experiencing the same problem too. I use a callback to change the upload_id, but the file still upload to the old upload_id

isCopyman avatar Nov 24 '21 09:11 isCopyman

I just create a random id for du.Upload() to prevent the same id but a different upload_id. Stupid but effective method

isCopyman avatar Nov 24 '21 15:11 isCopyman