0
votes

I am using @azure/storage-blob package to upload files to Azure blob.

Here is my code for upload files to Blob:

public uploadFilesToAzureBlob(sasToken: string, file: any, id: string): Observable<any> {
        const blobServiceClient = new BlobServiceClient(sasToken);
        const containerClient = blobServiceClient.getContainerClient(id);
    
        if (!containerClient.exists()) {
          containerClient.create();
        }
    
        const client = containerClient.getBlockBlobClient(file.name);
    
        // 10MB block size and 20 concurrency
        const response = client.uploadBrowserData(file, {
          blockSize: 10485760,
          concurrency: 20,
          blobHTTPHeaders: {
            blobContentType: file.type
          }
        });
    
        return from(response).pipe(map((res: any) => res), catchError(this.handleError));   } 
  



                                                                                                                            

Getting below errors after 5-10 seconds of uploading the files, though file/s is/are successfully uploaded...

Any suggestion?

Error # 1

ERROR Error: Uncaught (in promise): RestError: Failed to send request to https://AzureBlobStorage/Files/FBEB2AE9-B14C-4C78-8F4A-0CE4FF9DF6F5/EDB62F71-6D1C-4347-B277-0D0BF98B9A1E?sv=2017-04-17&sr=c&sig=AnlnrIFDingda21arBI1mbA0yu2mqtAYehDEWNB5tA4%3D&se=2020-09-19T08%3A07%3A49Z&sp=rwdl&restype=container&_=9311731167285
RestError: Failed to send request to https://AzureBlobStorage/Files/FBEB2AE9-B14C-4C78-8F4A-0CE4FF9DF6F5/EDB62F71-6D1C-4347-B277-0D0BF98B9A1E?sv=2017-04-1
    7&sr=c&sig=AnlnrIFDingda21arBI1mbA0yu2mqtAYehDEWNB5tA4%3D&se=2020-09-19T08%3A07%3A49Z&sp=rwdl&restype=container&_=9311731167285
at new RestError (restError.js:10)
at XMLHttpRequest. (xhrHttpClient.js:142)
at ZoneDelegate.invokeTask (zone-evergreen.js:399)
at Object.onInvokeTask (core.js:41344)
at ZoneDelegate.invokeTask (zone-evergreen.js:398)
at Zone.runTask (zone-evergreen.js:167)
at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:480)
at invokeTask (zone-evergreen.js:1621)
at XMLHttpRequest.globalZoneAwareCallback (zone-evergreen.js:1647)
at resolvePromise (zone-evergreen.js:798)
at zone-evergreen.js:705
at rejected (tslib.es6.js:72)
at ZoneDelegate.invoke (zone-evergreen.js:364)
at Object.onInvoke (core.js:41366)
at ZoneDelegate.invoke (zone-evergreen.js:363)
at Zone.run (zone-evergreen.js:123)
at zone-evergreen.js:857
at ZoneDelegate.invokeTask (zone-evergreen.js:399)
at Object.onInvokeTask (core.js:41344)

Error # 2

GET https:///Files/FBEB2AE9-B14C-4C78-8F4A-0CE4FF9DF6F5/EDB62F71-6D1C-4347-B277-0D0BF98B9A1E?sv=2017-04-17&sr=c&sig=AnlnrIFDingda21arBI1mbA0yu2mqtAYehDEWNB5tA4%3D&se=2020-09-19T08%3A07%3A49Z&sp=rwdl&restype=container&_=9311731167285 net::ERR_FAILED
1

1 Answers