Fine uploader sending PUT request to localhost

  Kiến thức lập trình

My uploader:

var uploader = new qq.azure.FineUploader({
    element: document.getElementById('uploader'),
    cors: {
        expected: true,
        sendCredentials: false
    },
    request: {
        endpoint: 'https://ACCOUNT_NAME.blob.core.windows.net/uploads' // URL to the server-side endpoint
    },
    signature: {
        endpoint: 'https://localhost:44302/Home/Sas'
    },
    uploadSuccess: {
        endpoint: '/success'
    },
    retry: {
        enableAuto: true
    },
    deleteFile: {
        enabled: true
    }
});

My Sas endpoint:

[HttpGet]
public async Task<string> Sas(string blobUri)
{
    var credentials = new StorageCredentials(STORAGE_ACCOUNT_NAME, STORAGE_ACCOUNT_KEY);
    var blob = new CloudBlockBlob(new Uri(blobUri), credentials);
    var sasParameters = new SharedAccessBlobPolicy()
    {
        SharedAccessExpiryTime = DateTime.UtcNow.AddHours(1),
        Permissions = SharedAccessBlobPermissions.Write
    };
    var sasToken = blob.GetSharedAccessSignature(sasParameters);
    var returnValue = blob.Uri.AbsoluteUri + sasToken;
    return returnValue;
}

This endpoint returns the following Sas:

https://ACCOUNT_NAME.blob.core.windows.net/uploads/1e67f8bc-ef5c-476a-9c22-b6bd1965531d.zip?sv=2018-03-28&sr=b&sig=awqJU%2BmP8ohL%2FvE1F9mrCdc57q52DNrx1yTDfyIF2IU%3D&se=2024-04-04T07%3A14%3A26Z&sp=w

The problem is that fine uploader is sending put request to incorrect URL (localhost) instead azure blob url:

XHRPUT
https://localhost:44302/"https://ACCOUNT_NAME.blob.core.windows.net/uploads/b5594a0b-4af3-4d6f-bcf6-b56f9c8723cb.zip?sv=2018-03-28&sr=b&sig=+5gNS54GN7Wx3/8puf897ertsTJF5YI4w6NSVQ38M8E=&se=2024-04-04T07:17:04Z&sp=w"
[HTTP/2 404  3ms]

enter image description here

I have tried changing the config from ‘request.endpoint’ to ‘request.containerUrl’, that didnt work either.

LEAVE A COMMENT