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

Kendo UI Angular UploadEvent async await

1 Answer 153 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
yogen
Top achievements
Rank 1
yogen asked on 24 Feb 2021, 06:17 AM

Hi,

 

How can I wait uploadevent to fire after other HTTP call inside that event?

Something like this below.

    public async uploadEventHandler(e: UploadEvent) {
        this.uploadSaveUrl = 'https://mycustom.blob.core.windows.net/';

       // Wait for server call to return SAS url.

       // Currently it just starts upload without waiting for await from server.
        this.uploadSaveUrl += await this.authService.getSAS().toPromise();
        const fileType = e.files.length && e.files[0].rawFile ? e.files[0].rawFile.type : '';
        e.headers = e.headers.append('x-ms-blob-content-type', fileType);
        e.headers = e.headers.append('content-type', fileType);
        e.headers = e.headers.append('x-ms-blob-type', 'BlockBlob');
    }

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 25 Feb 2021, 01:41 PM

Hello Yogen,

Basically, the upload event is used to send headers or any additional data with the item to the server. 

In case the developer wants to trigger the upload on a specific element (when autoUpload is set to false), the uploadFiles method can be used to upload files manually. For more details check the following article:

https://www.telerik.com/kendo-angular-ui/components/uploads/upload/how-to/external-btn-uploading/

Also, I want to mention that the FileSelect component is similar to the Upload, with the only difference that is used to select files from the file system only, leaving the rest of the process in the hands of the developer (the developer needs to decide when and how to send the request to the server, etc.). It can be used in this case to avoid dealing with asynchronous operations.

I hope this helps.

Regards,
Martin
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
General Discussions
Asked by
yogen
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or