Appologies, I didn't read the post correctly - the issue I had was
reading the file(s) in, your problem (like Ryan above said) is
uploading.

There are some bits available in mozilla which might help,
Canvas.mozGetAsFile() and FormData().
http://hacks.mozilla.org/2011/01/how-to-develop-a-html5-image-uploader/

I haven't played with any of these :o)

Like Ryan eluded to there is now probably/possibly more efficent ways
of "reading" (or not reading) the images in by loading the image in an
Image() and drawing it to a canvas using context.drawImage(...).

Cheers,
Dave

On Feb 19, 11:27 pm, Ryan Seddon <[email protected]> wrote:
> > Like you I've written a wrapper around the File api for DND file
> > upload (for use in GWT) and you're right there are memory problems...
> > what's happening is the files are being read into memory (FileReader)
> > which is obviously very inefficient.
>
> That's where create/revokeObjectURL comes in handy. FF4 and Chrome
> both
> support this method. It allows you to use a local file without having
> to load it
> into memory and will persist for the life of the document (think
> session storage).
>
> var file = event.dataTransfer.files[0],
>      video = document.createElement("video"),
>      objURL = window.URL.createObjectURL(file);
>
> video.src = objURL;
>
> Obvisoulsy I've simplified the above example for verbosity. In the
> real world Chrome uses
> window.webkitURL.createObjectURL() in the latest builds but also had
> window.createObjectURL().
>
> So the above code would end up looking something like this.
>
> var file = event.dataTransfer.files[0],
>      video = document.createElement("video"),
>      objURL;
>
> if("createObjectURL" in window || "URL" in window &&
>     "createObjectURL" in window.URL || "webkitURL" in window &&
>     "createObjectURL" in window.webkitURL) {
>
>         if("createObjectURL" in window) {
>             // Chrome exposes create/revokeObjectURL directly on
> window
>             objURL = window.createObjectURL(file);
>         } else if("webkitURL" in window) {
>             // Chrome exposes create/revokeObjectURL on the new
> webkitURL API
>             objURL = window.webkitURL.createObjectURL(file);
>         } else {
>             // FF4 exposes create/revokeObjectURL on the new URL API
>             objURL = window.URL.createObjectURL(file);
>         }
>
> } else {
>
>     // fallback to FileReader for FF3.6
>
> }
>
> video.src = objURL;
>
> -Ryan

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to