Hi Chris,
Sorry for not being clearer. I would like to show a preview of the
image before uploading the file via HttpRequest. I'm trying to do
this, but my sample code doesn't seem to work. My sample code
currently looks like:
for(var i=0; i<files.length; i++)
{
previewUrl = files[i].name + files[i].blob.length;
try {
store.captureBlob( files[i].blob, previewUrl );
} catch(ex) {
alert("Error capturing the file from " + files[i].name);
continue;
}
show_update(files[i], previewUrl);
}
This is invoked as the callback when files are selected via the
desktop.openFiles() method.
I've tried all sorts of variants for the definition of show_updates()
function, but I can't get an image to appear. As I read the docs,
previewUrl should be the "url" inside in the store. But, I can't seem
to get the data back out. A simple example for show_updates is:
function show_update(file, previewUrl)
{
$('img_queue').append("<div><img src=\"" + previewUrl +"\"><"+"/
div>");
}
But this doesn't show the image. In fact, nothing is shown.
The storage seems to work properly - that is, there are no exceptions
thown. However, i just can't get my data back out.
How do I construct an image url that references the store my gear has
created/opened?
Thanks
Dave
On Dec 10, 3:04 pm, Chris Prince <[email protected]> wrote:
> To upload the File.blob, you don't need to store it in the DB. Just
> pass the blob to HttpRequest.
>
> On Wed, Dec 10, 2008 at 1:31 PM, dviner <[email protected]> wrote:
>
> > Hi,
>
> > I'm new to Gears, and I'd like to build a Gear that enables users to
> > select one or more local image files, enter in some metadata about
> > them, and upload them to a specified website whenever they are
> > connected to the network.
>
> > I know that there is a Desktop module has an openFiles() method,
> > documented athttp://code.google.com/apis/gears/api_desktop.html#Desktop
> > which creates a dialog window allowing the user to select one or more
> > files. However, it appears that the callback function will only
> > receive the file name (not the path) as documented at
> >http://code.google.com/apis/gears/api_desktop.html#File.
>
> > Is there a way to access or retrieve the file path?
>
> > I believe that I could circumvent this problem by using the File.blob
> > property to store the full contents of the image file into a Gears
> > DB. But, this seems like a poor approach for a few reasons. First,
> > it requires duplicate storage of the entire file which is actually
> > unnecessary. Second, it limits the file size to 2GB (or more exactly,
> > to 2,147,483,647 bytes). Both of these are hard to overcome for
> > simple photo uploading. (And video uploading is even worse, since
> > many files are larger than 2GB).
>
> > Thanks
> > Dave