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

How to set the file uid after upload in the Upload Component

3 Answers 1048 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dennis
Top achievements
Rank 1
Dennis asked on 03 Oct 2018, 10:42 AM

I use the Kendo Angular Upload component to send files to the server where they are stored in the database. After a successful upload, the Upload Component automatically adds the uploaded file to the list on the screen. In the FileInfo for the newly uploaded file the property 'uid' is set to a randomly generated ID.

How can use the (primary key) ID used by the server as the uid of the newly uploaded file? I can send the server generated uid in the response of the upload request, but how can I get the Upload Component to use it?

3 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 05 Oct 2018, 08:05 AM
Hi Dennis,


Replacing the uid is currently not supported, the Upload component uses it to access the files internally. Could you elaborate why is this needed in the current case, so I could suggest an alternative approach?

I am looking forward to hearing from you.

Regards,
Dimiter Madjarov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Dennis
Top achievements
Rank 1
answered on 05 Oct 2018, 08:10 AM
After uploading a file, you need to be able to delete the file using the remove function. The server uses an auto increment primary key as the unique identifier. They way the upload component works now, the only option is to also store the Kendo generated UID in the database. Otherwise the server can't uniquely identify which file to delete.
0
Accepted
Dimiter Madjarov
Telerik team
answered on 05 Oct 2018, 11:30 AM
Hello Dennis,


Thank you for providing the additional information. In this case, I would suggest to create a custom FileInfo class that implements our FileInfo interface

https://www.telerik.com/kendo-angular-ui/components/upload/api/FileInfo/

and adds an additional field for the id, returned from the server. This field could be set in the success event handler and also send back to the server as additional data in the remove event handler

http://https//www.telerik.com/kendo-angular-ui/components/upload/credentials/#toc-attaching-additional-data-to-requests

Here is an example that demonstrates this in action

https://stackblitz.com/edit/angular-57ylpc?file=app/upload.component.ts

Regards,
Dimiter Madjarov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
General Discussions
Asked by
Dennis
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Dennis
Top achievements
Rank 1
Share this question
or