Hi,
captureBlob() allows you to assign an URL to a blob object. Handles to blob
objects can be obtained via the Desktop API. This sample here demonstrates
how to capture a local binary file as a blob and assign it to an URL -
window.desktop = google.gears.factory.create('beta.desktop');
window.localServer = google.gears.factory.create('beta.localserver');
window.store = window.localServer.createStore('test-store');
desktop.openFiles(function(files) {
for (var i = 0; i < files.length; i++) {
var file = files[i];
var filename = file.name;
var fileblob = file.blob;
var url = 'http://' + document.location.host + '/' + filename;
store.captureBlob(fileblob, url);
var link = document.createElement('a');
link.href = url;
link.innerHTML = 'file';
document.body.appendChild(link);
document.body.appendChild('<br>');
}
});
When you run the above code, you can select a local file (ie "foo.jpg").
After you do that, you can access this image by going to "
http://yourdomain.com/foo.jpg". This URL has offline access as well.
Hope that helps,
Austin
On Thu, Dec 18, 2008 at 5:16 PM, rDx <[email protected]> wrote:
>
> I work on this project which needs large files to be uploaded on to
> the server. My plan is to get the file blob chunk it and send chunk by
> chuck to the server, I have the server code all figured out to glue
> the file and so on....
>
> after going thru gears documentation and message boards I released
> that gears doesn't support blobs to be stored in the sqllite db...only
> way to get this going is to
> Generate a unique URL for the blob; store the same in the db.....
> I tried and couldn't get this quite right.
>
> It will be great if someone points me to a code sample or some pseudo
> code....
>