-1

Below is an ajax PUT request i use to upload 1 minute video to a server. The file is read by a filereader.

It works fully on Firefox and Edge. It works on Chrome for file size below 106 Mega Byte

BUT it failed for a file of 175 Mega Byte

Here is the request :

    $.ajax({
        url: urlToS3,
        type: 'PUT',
        cache: false,
        processData: false, 
        data: reader.result, //video file read using filereader
        async: true,  
        success: fnSuccess,
        error: fnError,
        crossDomain: true,

        contentType: false,
        xhr: function() {
                    xhr = new window.XMLHttpRequest();    //xhr is a global variable
                    xhr.upload.onprogress = function (evt){fnOnprogress(evt);} ;
                    xhr.upload.onload = fnOnload;
                    xhr.upload.onerror = fnOnerror; 
                    return xhr;
                  },
}, 'json');     //$.ajax({

Tests:

failure on chrome : reader.result.byteLength= 183190491

sucess on chrome reader.result.byteLength= 127838343

alvaro562003
  • 678
  • 1
  • 6
  • 27

1 Answers1

0

I solve the issue by changing the method. I do not use anymore FileReader. I am doing like this :

    var file = document.getElementById('_testFile').files[0];

$.ajax({
    url: "/attachmentURL",
    type: "POST",
    data: file,
    processData: false
});

});

Credit to : Posting File Input as FileReader Binary Data through AJAX Post

alvaro562003
  • 678
  • 1
  • 6
  • 27