File upload bufferization

173 views
Skip to first unread message

Andrey Minogin

unread,
Mar 15, 2012, 9:20:36 AM3/15/12
to lib-gw...@googlegroups.com
Hello,
Great work!
Is it possible to upload a file to the server slice by slice? What methods should I use for that?

Lukas Laag

unread,
Mar 19, 2012, 3:36:59 PM3/19/12
to lib-gw...@googlegroups.com
Hi Andrey,

Sorry for the long delay in answering your mail. Uploading a file
slice by slice is theoretically possible, but as I discovered while
trying to create a sample answer to your request, does not currently
work.

Normally, all you need to do is to call the Blob.slice method (as File
inherits from blob) to split your file in as many chunks as requested.

However the specification seems to have changed recently (there is a
new draft dated 29 February 2012), redefining the semantic of the
slice method. The new semantic does not seem to be implemented yet
(not in FF11 and Chrome18 at least). The old implementations still
exist, but under a new name (mozSlice, webkitSlice, ... see:
http://dev.w3.org/2006/webapi/FileAPI/#slide-method-algo). The
difference lies in the way a slice is defined: by (start-offset,
length) in the old way, by (start-offset, end-offset) in the new way.

What I am currently contemplating is to fix the current 0.3 release
into a 0.3.1 release. In this upgrade release, I would:
+ Update the documentation of the slice methods (there is a new
overload for the method too). We will need to wait for a few more
browser iterations for the browser vendors to implement the new spec.
+ Create a new set of methods (called slice_) which will let you call
the old implementations, so you can code something today.
+ Mark the slice_ method deprecated to note the fact that they are not
part of the spec any more and will be someday removed from browsers.

I need to read the new spec with a fine tooth comb to see if other
significant changes are required. I will post as soon as I know more
or have something available

Regards

Lukas

Trogdan

unread,
Mar 26, 2012, 10:17:26 AM3/26/12
to lib-gwt-file
Lukas,

So will your current 0.3 release work with older versions of Chrome/
FF? You mention including the old implementations so we can code
something today. I unfortunately only have a week to work on this, so
need to get file slicing working ASAP.

Lukas Laag

unread,
Mar 26, 2012, 3:58:49 PM3/26/12
to lib-gw...@googlegroups.com, Trogdan
Hi Trogdan,

I am in the process of transitioning all my projects to github,
including lib-gwt-file. I have uploaded the latest snapshot
(lib-gwt-file-0.3.1-SNAPSHOT) to the corresponding github repository:

https://github.com/laaglu/lib-gwt-file

I have looked at the documentation in MDN and done some tests with the
latest firefox (11) and chromium (19). Currently both browers have
removed the old slice method. They have already implemented the new
slice methods, under the name mozSlice and webkitSlice. Mozilla plans to
unprefix the new method in FF13, I do not know the plans for Chromium to
unprefix their slice methods.

So from my point of view, the only way to make slice work today is to
use the prefixed methods. This is what I have done in the snapshot (you
can see the details of the modifications here:
https://github.com/laaglu/lib-gwt-file/commit/41db1772fcb9f0e7af97e3b3ada1ed54c756604d)

I have done a few tests in which I sliced SVG files and later
reconstructed them and it seemed to work.

I plan to do some more tests, possibly upload my sample to demonstrate
the use of slice, and then finalize lib-gwt-file-0.3.1. Depending on the
progress of my global github migration, this might happen before the end
of the week, but I cannot make any firm commitments.

Regards

Lukas

Greve Dan

unread,
Mar 26, 2012, 4:07:18 PM3/26/12
to lib-gw...@googlegroups.com
Very good, thanks for the update Lukas.  I will keep up to date with your mods in Git.  I did find your test code at least for the older library, so I have a better idea of the overall design better.  

I think your solution for the api changes sounds good, it's hard to keep up with this spec.  

One last question, do the changes (mozSlice/webkitSlice) only affect firefox 11 and chromium 19 and later, or do these changes get rolled back into their older browsers?

dan

Lukas Laag

unread,
Mar 27, 2012, 5:21:02 PM3/27/12
to lib-gw...@googlegroups.com
Hi,
From what I have read on the web, mozSlice exists since FF5 and
webkitSlice since Chrome11
Lukas

Trogdan

unread,
Mar 29, 2012, 4:57:43 PM3/29/12
to lib-gwt-file
Hey Lukas. I used a snapshot of your Git repository from 2 days ago.
Just thought I'd give you a little feedback. Chrome 17 file slicing
works, Firefox 9 doesn't appear to work....

Also, there appears to be a fairly large memory leak between chrome
and the FileReader class.

Cheers!
Dan
> >>https://github.com/laaglu/lib-gwt-file/commit/41db1772fcb9f0e7af97e3b...)

Lukas Laag

unread,
Mar 29, 2012, 5:10:15 PM3/29/12
to lib-gw...@googlegroups.com
Hi,

Thanks for the feedback. I have updated my sample application tonight
(https://github.com/laaglu/lib-gwt-file-test/commit/0588f39cb624e755004132d359ac84b577ca9c4e).
It can now open text files and I slice the file to display only the
first 1000 characters. It seems to work in FF11 and Chromium19. Can
you give more details on the scenario which does not work for you in
FF9 ?

Regards

Lukas

Trogdan

unread,
Mar 30, 2012, 1:12:22 PM3/30/12
to lib-gwt-file
The issue with FF9 was running GWT in development mode through Jetty.
Initially. the FileReader.readAsBinaryFile call hung. After further
testing, my environment was just very laggy with FF9, most of the time
FF just freezes when clicking anywhere on the web page.

Running outside of dev mode, as a native war inside of Tomcat seems to
work fine with Chromium 19 and FF9 and FF12.

No memory leaks, performance is excellent, chunking up multi-gig files
and uploading via RPC quickly. I will be putting a sample project up
somewhere to demonstrate, will link this on the group when i do

Dan

On Mar 29, 5:10 pm, Lukas Laag <laa...@gmail.com> wrote:
> Hi,
>
> Thanks for the feedback. I have updated my sample application tonight
> (https://github.com/laaglu/lib-gwt-file-test/commit/0588f39cb624e75500...).

Ericsson de Oliveira

unread,
Mar 26, 2013, 3:02:24 PM3/26/13
to lib-gw...@googlegroups.com
Hello Dan,
i saw that you uploaded files via RPC, can you please share the sample? i trying here and is not good -_-

Thanks.

Ericsson

Dan Greve

unread,
Mar 26, 2013, 10:28:25 PM3/26/13
to lib-gw...@googlegroups.com
Ericsson,

sure, will try to get some sample code up this week.


--
You received this message because you are subscribed to the Google Groups "lib-gwt-file" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lib-gwt-file...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dan Greve

unread,
Mar 29, 2013, 11:04:42 AM3/29/13
to lib-gw...@googlegroups.com
Ericsson, haven't forgot about you, throwing together a new project with the latest GWT versions. Looking at doing this over the weekend

Dan Greve

unread,
Mar 31, 2013, 2:11:24 PM3/31/13
to lib-gw...@googlegroups.com
Ericsson, check out the sample code at https://github.com/trogdan/gwt-slicedfileupload

Enjoy

Ericsson de Oliveira

unread,
Apr 1, 2013, 2:47:46 PM4/1/13
to lib-gw...@googlegroups.com
Dan,
 thank you so much.
I adapted your code to my app, now it upload files via dnd. I think my error was the handler of the reader was inside the drop handler. It was giving me error 500 sometimes. But now is all good. Thanks again.

Dan Greve

unread,
Apr 1, 2013, 2:53:51 PM4/1/13
to lib-gw...@googlegroups.com
My pleasure Ericsson
Reply all
Reply to author
Forward
0 new messages