FineUploader / fine-uploader

Multiple file upload plugin with image previews, drag and drop, progress bars. S3 and Azure support, image scaling, form support, chunking, resume, pause, and tons of other features.
https://fineuploader.com
MIT License
8.18k stars 1.87k forks source link

Allow access and modification of the chunk data in the onUploadChunk event #1523

Open ericmackrodt opened 8 years ago

ericmackrodt commented 8 years ago

I'm opening this feature request based on the Pull Request #1516 that I opened previously.

As an use case in my company, we need to be able to encrypt each chunk separately when uploading a file. In order to do that, we need access to the blobs of the chunks on the onUploadChunk event (with asynchronous code support) so we can modify them.

Of course there has to be a validation so the chunk size (except for the last one) doesn't change, as it would break the code.

As a workaround, I implemented a new event called onProcessingChunkData that allows me to do that and created a pull request, but it was rejected as there were too many modifications to the code. This is the reason I am now opening a feature request.

I believe that this an important feature to have in the library to allow more flexibility and I've seen other people on the internet who needed to do something similar. Here's an example:

http://stackoverflow.com/questions/31051664/how-to-modify-current-chunk-data-during-upload-process-with-fineuploader

The way I see it, if the developer use this feature the wrong way and breaks their upload flow, it's entirely their responsibility. Of course, to help to prevent that, there should be validations as the one that I mentioned before.

I hope that you guys can implement this feature as it would be really helpful to have it officially supported by the library.

Thanks in advance for the attention.

rnicholus commented 8 years ago

Including my initial suggestion for implementation from #1516 here...

I think this can be accomplished for traditional endpoints by extending the onUploadChunk event/callback. Currently, Fine Uploader passes metadata about the chunk to the callback handler, just before it is uploaded. The code could be modified to include the chunk Blob as well. Furthermore, internal code that handles onUploadChunk calls could be modified to support a promissory return type that, when resolved, includes the new chunk Blob. I don't think this will be a terribly difficult modification to make.

That said, version 6.0 is already in progress, and that is quite an ambitious release already based on the cases still yet to be completed. So earliest version would be sometime post 6.0.

ericmackrodt commented 8 years ago

Okay, if it's possible to leave it open, I'll try to get around to implement it, If I can't, if you could implement it for a post 6.0 release, it'd be awesome.

Thanks for the quick response.

bebraw commented 8 years ago

@ericmackrodt Did you have any luck with this?