0

I've been using FineUploader for many versions now and I LOVE what you guys have done. This is regarding v5.3.0 using the jquery wrapper.

The project I'm currently working on needs to chunk the files (some are as big as 2GB), and I've gotten the chunking to work, kinda. I can upload a few chunks, and that's about it.

The chunking process that I've created makes a folder based on the qqUUID, and drops the chunks into this folder. The chunks are named only by their qqpartindex (0, 1, 2, etc) so they can be ordered later and rebuilt. At this point I haven't gotten this far yet, so please correct me if this is wrong. I'm only able to save 3 files before I get an error (for a 20mb test file). I'm getting this error: 'XHR returned a response code 0', though I'm not cross site scripting (locally running app, with correct permissions on network resources to save), and I can ALWAYS save 3 files and that's it. Strange that I can get some to work, but that's it. What am I missing? Thanks for your help!

See the client side fineuploader code below, which works:

<script type="text/javascript">
var filesToUpload = 0;
var uploadedFileCounter = 0;
var po = '@Model.PurchaseOrder';
var companyNumber = '@Model.CompanyNumber';

$().ready(function () {
    var fineuploader = $('#files-upload').fineUploader({
        debug: false,
        template: 'qq-template',
        button: $("#uploadButton"),
        request:
        {
            endpoint: '@Url.Action("UploadFile", "Upload")',
            forceMultipart: true,
            customHeaders: { Accept: 'application/json' },
            params: {
                po: (function () { return po; }),
                companyNumber: (function () { return companyNumber; }),
            }
        },
        validation: {
            acceptFiles: ['image/*', +                   
                'audio/mp4a-latm'],
            allowedExtensions: ['jpeg', 'jpg', 'gif', 'png', 'bmp', 'm4a'],
            sizeLimit: 1024 * 1024 * 1024 * 2, // 2 GB
            stopOnFirstInvalidFile: false
        },
        chunking: {
            enabled: true,
            concurrent: {
                enabled: true
            },
            mandatory: true,
            success: {
                endpoint: '@Url.Action("UploadChunksComplete", "Upload")'
            }
            //, expected: false  // allow cross-domain requests
        },
        failedUploadTextDisplay: {
            mode: 'custom'
        },
        multiple: true
    }).on('submitted', function (event, id, filename) {                        
        filesToUpload++;
        $(':input[type=button], :input[type=submit], :input[type=reset]').attr('disabled', 'disabled');            
    }).on('complete', function (event, id, filename, responseJSON) {
        uploadedFileCounter++;
        if (filesToUpload == uploadedFileCounter) {
            $(':input[type=button], :input[type=submit], :input[type=reset]').removeAttr('disabled');
                        }
    }).on('error', function (event, id, name, errorReason, xhr) {
        alert('error: ' + errorReason);            
    });
});

The server side code for chunks looks like this, which 'works' and I can step into it:

 [HttpPost]
    public HttpResponseMessage UploadFile(HttpPostedFileWrapper qqfile, string po, string companyNumber)
    {            
        var id = Request["qquuid"];
        var filename = (Request["qqpartindex"]); 

        var x = FileProcessor.Storage.SaveChunk(qqfile, id, filename, Config.Instance.TemporaryChunkDirectory);

        var response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK };
        return response; 
    }     

The SaveChunk Method, which is part of a separate project is shown below:

 public static bool SaveChunk(HttpPostedFileWrapper file, string id, string filename, string fileTemporarySavePath)
    {
        if (!VerifyFile(file)) { return false; }

        if (filename == null) { filename = "0"; } // creating index 0 for files that don't actually need chunk

        Common.CreateTempDirectory(fileTemporarySavePath, id);            

        try
        {
            var pathfilename = string.Join("\\", fileTemporarySavePath, id, filename);
            file.SaveAs(pathfilename);

            return true;
        }
        catch (Exception ex)
        {
            var error = ex.Message.ToString();
            return false;
        }
    }
RichieMN
  • 905
  • 1
  • 12
  • 33
  • Did you recently turn on the `chunking.concurrent` option? Does everything work fine with that turned off? – Ray Nicholus Sep 14 '15 at 18:40
  • It doesn't work whether it's enabled or not. Console currently shows this: [Fine Uploader 5.3.0] Error when attempting to parse xhr response text (Unexpected token S) (line 249 qq.log - window.console[level](message); ) – RichieMN Sep 14 '15 at 18:51

2 Answers2

1

I needed to add the

{"success":true}

to the body of the request, not just return the OK status in the header. My bad. Onto the next task, thanks!

RichieMN
  • 905
  • 1
  • 12
  • 33
0

Response code 0 usually indicates some network issue between the client and the server. More specifically, it my be an indication that a completely empty response was received (no headers or payload). This may happen if the network connection between client and server is dropped, or if the server is failing in some place and returning an empty response due to an unchecked error.

Ray Nicholus
  • 19,538
  • 14
  • 59
  • 82
  • Besides a 200 being sent back in the response for each chunk, am I missing something else? – RichieMN Sep 14 '15 at 19:30
  • If the browser is reporting status 0, then a 200 is not being returned, or at least that response is not making its way to the browser. – Ray Nicholus Sep 14 '15 at 19:43