Blueimp jquery Upload throwing 'Empty file upload result' error with ASP.Net Core 3.1

207 Views Asked by At

I am using blueimp file upload plugin to upload files in ASP.Net Core 3.1 project. The upload does call the URL but fails to actually upload the given file and throws a "Empty file upload result" error. The same code was working fine with ASP.Net Core 2.2 but is now not working after upgrade to 3.1

My JS code :

$('#fileupload').fileupload({
    url: url,
    acceptFileTypes: /(jpg)|(jpeg)|(png)|(gif)|(svg)$/i,
    maxFileSize: 1048576,
    maxNumberOfFiles: 1
}).on("fileuploaddone", function (e, data) {  
    
   
});

Server side code

public async Task<JsonResult> Upload(Guid id)
{
        try
        {
            var resultList = UploadAndReturnResult(Guid id)
            JsonFiles files = new JsonFiles(resultList);
            
            return Json(files);
        }
        catch (Exception e)
        {               
            return Json("Error ");
        }            
}

The structure of resultList and files :

//The resultList model
public class ViewDataUploadFilesResult
{
    public string id { get; set; }
    public string name { get; set; }
    public int size { get; set; }
    public string type { get; set; }
    public string url { get; set; }
    public string deleteUrl { get; set; }
    public string thumbnailUrl { get; set; }
    public string deleteType { get; set; }
    public string dateCreated { get; set; }
    public bool? isOwner { get; set; }
}

public class JsonFiles
{
    public ViewDataUploadFilesResult[] files;

    public JsonFiles(List<ViewDataUploadFilesResult> filesList)
    {
        files = new ViewDataUploadFilesResult[filesList.Count];
        for (int i = 0; i < filesList.Count; i++)
        {
            files[i] = filesList.ElementAt(i);
        }
    }
}

There is a similar issue which does not look like it has been resolved. Any idea as to how to approach in fixing it?

0

There are 0 best solutions below