Fineuploader with Azure, Empty image problem

160 Views Asked by At

I am using fineuploader's direct azure upload module for a long time. I am having difficulties with uploaded images. The problem is, sometimes uploaded images are empty. When I view it from Storage Explorer, file exists but the size is 0 kb. And when I view the image from browser it comes blank.

Code of the plug-in

var uploader = new qq.azure.FineUploader({
    debug: true,
    element: document.getElementById('fine-uploader'),
    request: {
        endpoint: 'https://xxxxx.blob.core.windows.net/assetscontainer'
    },
    signature: {
        endpoint: '/File/GetSasKey',
        cors: {
            expected: true,
            sendCredentials: false
        }
    },
    uploadSuccess: {
        endpoint: '/File/Success'
    },
    deleteFile: {
        enabled: true
    },
    callbacks: {
        onSubmit: function (id, name) {
            var extension = name.substr((name.lastIndexOf('.') + 1));
            var uuid = this.getUuid(id);
            this.setUuid(id, "JobOrder_" + uuid);
            this.setUploadSuccessParams({ entityID: 0, entityType: "orderID" }, id)

        },
        onComplete: function (id, fileName, responseJSON) {

            console.log(responseJSON);
        }
    }
});

Code of the sas generation process

[Route("sas")]
[HttpGet]
[AuthorizationType("*")]
public async Task<string> GetSasKey(string blobUri)
{
    var credentials = new StorageCredentials("xxxxxxxxxxxx", "afxxxxxasfasf==");
    var blob = new CloudBlockBlob(new Uri(blobUri), credentials);
    var storageAccount = new CloudStorageAccount(credentials, true);


    var sasParameters = new SharedAccessBlobPolicy()
    {
        SharedAccessExpiryTime = DateTime.UtcNow.AddHours(1),
        Permissions = SharedAccessBlobPermissions.Write | SharedAccessBlobPermissions.Delete
    };
    var sasToken = blob.GetSharedAccessSignature(sasParameters);
    var returnValue = blob.Uri.AbsoluteUri + sasToken;
    return returnValue;
}

And the success method

public JsonResult Success (string blob, string uuid, string name, string container, int entityID, string entityType)
{
    //do some work
}
1

There are 1 best solutions below

1
Shiraz Bhaiji On

This may be a problem with Fine Uploader.

Fine Uploader is an open source project that was shut down over a year ago.

https://github.com/FineUploader/fine-uploader/issues/2073

Having a dependency on an inactive open source project can be problem if a security bug is discovered in the code.

My advice would be to replace Fine Uploader.