s3_direct_upload
s3_direct_upload copied to clipboard
[ToDiscuss] Using $.widget ?
I started today using this awesome gem, it is much nicer than copying the Railscast code into each project. Additionally, the provided Javascript callbacks make it easy to adjust the plugin to some special needs.
Nevertheless, I felt that the callbacks were quite difficult to use (e.g. before_add
in options while others using bind
, and they have different names than the events from fileupload widget), so I started refactoring the client code into a $.widget
. Do you have any thoughts on this? Of course it isn't backwards-compatible, but I think the API is much easier to use.
List of changes:
- Plugin is initialized thorugh
$("#myS3Uploader").s3upload
instead of$("#myS3Uploader").S3Uploader
- Renamed events:
s3_upload_complete
=>s3uploaddone
,s3_upload_failed
=>s3uploadfail
- Introduce
progress
event that passesloaded
,total
andpercentage
properties - Pass additional
filekey
property todone
callback
I generally like this idea a lot. It makes things more modular and using the $.widget syntax is what the jquery file upload ui uses so it provides a more consistant syntax in this small eco-system.
Have you tested this code on all browsers?
I only tested the code on IE9, FF and Chrome, but we will do some more testing as soon we ship our code to production (I don't expect any problems since fileupload is also based on $.widget).
Okay, tI encountered no bugs on my refactoring. Shall I start working on rebasing my code on your current master so that we can merge it very soon, are you still interested in my changes?
Yes, that sounds great, I will merge it in when you rebase on master.
Out of curiosity, will this change facilitate usage of the standard jquery file upload UI? I actually prefer the load then start style UI with completion indicators.
I had a quick look at rebasing this but it's diverged pretty far from master by now.