Is there a solution for downloading files using JavaScript and Google Gears?

So, I used this file upload method a bit, but it seems that Google Gears does not support new browsers that implement the HTML5 specifications poorly. I heard the word deprecated , floating across multiple channels, so I'm looking for a replacement that can perform the following tasks and support new browsers. I can always go back to the transmissions / standard POST files, but these following elements simplify my process:

  • Users MUST be able to select multiple files to upload in the dialog box.
  • I MUST be able to receive status updates when transferring a file. (progress indicators)
  • I would like to use PUT requests instead of POST
  • I would like to be able to easily attach these events to existing HTML elements using JavaScript. I.E. file selection should be activated by pressing <button> .
  • I would like to easily manage response / request parameters using JavaScript.

I'm not sure if the new HTML5 browsers have support for object / query engines, or if there is a flash loader that has these features that I miss in my Google searches.

An example of loading code using gears:

 // select some files: var desktop = google.gears.factory.create('beta.desktop'); desktop.openFiles(selectFilesCallback); function selectFilesCallback(files) { $.each(files,function(k,file) { // this code actually goes through a queue, and creates some status bars // but it is unimportant to show here... sendFile(file); }); } function sendFile(file) { google.gears.factory.create('beta.httprequest'); request.open('PUT', upl.url); request.setRequestHeader('filename', file.name); request.upload.onprogress = function(e) { // gives me % status updates... allows e.loaded/e.total }; request.onreadystatechange = function() { if (request.readyState == 4) { // completed the upload! } }; request.send(file.blob); return request; } 

Edit: Apparently, flash is not able to use PUT requests, so I changed it to "how" and not to "must".

+6
javascript html flash file-upload google-gears
source share
2 answers

(It is created from the commentary on the original question, at the suggestion of each of them.)

Plupload is one of the newest children on the block, and it uses the best available method (HTML 5, Flash, Gears, Silverlight): http://plupload.com/

+1
source share

Previously, I used flash files such as http://www.webresourcesdepot.com/open-source-flash-uploader-multi-bit-shift/ . They work fine and depend only on flash memory on most computers. I did not find a reliable way to do this with js, but flash could be controlled with js - especially if you are writing your own.

hope this helps.

+1
source share

All Articles