Problem with Upload component's retry button when using it after modifying file externally

1 Answer 45 Views
Upload
Povilas
Top achievements
Rank 1
Povilas asked on 06 Feb 2023, 03:36 PM | edited on 06 Feb 2023, 03:51 PM

Hi.

I am having issue with upload component when uploading a single file. I am using @progress/kendo-angular-upload version 9.0.3. Angluar version 14.

When I select a file, upload it and get non-successful HTTP status code back from back-end (e.g. CSV file header validation didn't pass), then I get retry and remove buttons. When I click retry button, it retries to upload same file with POST request with all correct HTTP headers.

However, if I modify the file externally (e.g. by fixing CSV file header), save it and then try clicking retry button, upload component issues incorrect HTTP request to the back-end, various HTTP request headers are missing (e.g. it no longer specifies that it is a POST request). After inspecting 'good' failing POST request with 'bad' request, other than obviously missing HTTP headers I can see that the actual file which is being uploaded has incorrect modified date and size. Looks like that when I click retry button after modifying the file externally, upload component no longer works correctly.

Is this intended behavior due to browser nuances and how it works with files, or is this a bug? Or maybe I am doing something wrong...

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 09 Feb 2023, 09:30 AM

Hi Povilas,

Based on the provided details I am not sure how this retry feature was implemented and which methods are being used. Generally, you could subscribe to the (error) event and use it to display a custom retry button and capture the uid of the failed file upload. Then, once the "retry" button is clicked, the failed file's uid can be passed to the Upload's retryUploadByUid() method in order to be uploaded again.

But things changed when the file is modified in the file system.

Basically, Kendo UI for Angular is executed in the browser. This is why, when a file is selected using the Keno UI for Angular Upload component it is stored in the browser memory from where it can be sent to a remote server API or processed as desired. If that same file is modified on the file system (not within the browser), then it has to be added to the browser again in order to be able to process it with its latest updates. Providing access from the browser to the file system via JavaScript would impose significant security concerns, which is a limitation for the specific requirement. Please check the following resource online for some more details on the topic:

https://stackoverflow.com/questions/371875/local-file-access-with-javascript

In case that didn't help much and further assistance is required, please provide some more details about the implementation or ideally a runnable sample, which reproduces the described issue. Thus we would be able to inspect the code and provide a more valuable solution to the case. Thank you for your understanding. 

Regards,
Martin
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Upload
Asked by
Povilas
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or