This is a migrated thread and some comments may be shown as answers.

Per File Meta-info in Async Mode with AutoUpload

2 Answers 73 Views
Upload
This is a migrated thread and some comments may be shown as answers.
François
Top achievements
Rank 1
François asked on 09 Sep 2014, 08:43 PM
Hi Guys
When the user drags a bunch of files into the upload widget, the files are being stored on the server and a logical file incl. a file version is being created
in the database backend assigning a unique ID to each uploaded file. I modified the widged in a way that the user can meanwhile edit some meta informations
like the name, the responsible person, whether a pdf view shall be generated and so on. This happens simultaneously while uploading on a "per file base". When all files are uploaded completely a button becomes active to commit all meta information. The problem is, that at this point (when the commit button is pressed after uploading all files), I need to know, which local "row" has which FileID on the server.

I didn't think this would be a problem in the first place as I realized, that a separate "upload" event and corresponding "save" request is being performed for each file (even when selecting multiple files at once). So I thought, I simply send the uid to the server by evt.data = {uid: file.uid) and the "save" handler on the server side returns a tuple (uid, FileID) which I can catch in the success event and assign the fileID to the matching DOM element containing the appropriate uid data attribute. What I didn't realize was, that it seems to be impossible to know for which file a "upload" event is being fired, so I don't know which uid to select as I always get the entire array of selected files.

Am I missing something here?

Best regards

2 Answers, 1 is accepted

Sort by
0
François
Top achievements
Rank 1
answered on 09 Sep 2014, 09:39 PM
I just realized that "upload" that the files array size in each call of "upload" is only one and contains the very specific file (incl. the uid) for which this event was called. So association of uid to fileid is possible. But what about if the browser is not able to call separate requests for each file and the system falls back to batching? I suppose then I get only a single call to "upload" and the array contains the whole bunch of selected files? Any idea how I could do this association in such a case?
0
Dimiter Madjarov
Telerik team
answered on 10 Sep 2014, 01:17 PM
Hello Francois,


Thanks for the detailed explanation. I don't think that the fallback will be necessary, as in basically every Kendo UI supported browser, the files will be uploaded in separate requests, when the async.batch option is set to false e.g. IE 7+, Chrome, Firefox 4+. In the case when the async.batch option is enabled, all files selected at once, will be placed in a single list item and will share a common uid, so the current approach won't be applicable.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Upload
Asked by
François
Top achievements
Rank 1
Answers by
François
Top achievements
Rank 1
Dimiter Madjarov
Telerik team
Share this question
or