Reputation: 11
I need to process binary data of every file that is uploaded to Amazon S3 through (with and without chunking). Do you know if there is any function/signal in Fineuploader that I could use to process every binary chunk/file ?:
For example:
preupload(data_chunk)
process(data_chunk);
return data_chunk
This would be very useful for my project.
Cheers, Piotr
Upvotes: 1
Views: 699
Reputation: 19890
The easiest way to do this would be to grab the File
/Blob
in a submit
event handler, return false from your handler (to tell Fine Uploader to ignore the file), process it, then send the processed file back to Fine Upload via the addBlobs
method. You'll need to be sure that your submit event handler knows which files to process/ignore and which files to "leave alone". One way you can do this is to add a property to the processed Blob
that your submit event handler looks for.
Since Stack Overflow's code editor is awful, I've created a gist to demonstrate this.
function process(file) {
var processedVersion = /*do stuff and return a processed version */
processedVersion.processedByMyApp = true;
uploader.addBlobs(processedVersion);
}
var uploader = new qq.FineUploader({
request: {
endpoint: "/uploads"
},
callbacks: {
onSubmit: function(id) {
var file = this.getFile(id);
if (!file.processedByMyApp) {
process(file);
return false;
}
}
}
});
Upvotes: 3