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;
}
}