I don't think Gears will get you the filepath for security reasons.
(However, I might be wrong here, so feel free to correct me.) Gears
*does* provide an api to import (i.e. capture) the file to a local
store, and you can specify the file path url to display. For example:
gears.desktop = gears.factory.create('beta.desktop');
gears.localserver = gears.factory.create('beta.localserver');
gears.filestore = gears.localserver.createStore('filestore');
gears.desktop.openFiles(function(files) {
for (var i = 0; i < files.length; i++) {
gears.filestore.captureBlob(files[i].blob, '/path/of/your/choice/'
+ files[i].name);
// more code...
}
});
*** To get the files from the local store to access them (e.g. to
upload), use the getAsBlob('/path/of/your/choice' + filename) from the
LocalServer API.
http://code.google.com/apis/gears/api_localserver.html#LocalServer.
If you just want to access them through an img tag, then you can just
do <img src="/path/of/your/choice/filename.jpg"/>.
The '/path/of/your/choice' doesn't seem to have to be a real path...
(I don't know if that's a good practice or not?) In my app, I just
specified some sort of standardized path. To access the file, I would
just do something like <img src="/path/of/my/choice/filename1.jpg"/>.
Gears "knows" how to access that uri that you specify for the
filename.
And of course, the API for Desktop is here:
http://code.google.com/apis/gears/api_desktop.html
You can also use the Gears sqlite database to store the filenames too.
Hope this helps.
On Apr 21, 10:15 pm, skunkwerk <[email protected]> wrote:
> i'm using gears to write a local application, and i need to be able to
> get the full path of a file (such as an image) so i can insert it into
> my rich text editor. thanks to firefox's wonderful new security
> policy, i can no longer use a simple <input type='file'> to retrieve
> that value - all i get is the file name. i then tried the openFiles
> function in the desktop api of gears, but lo and behold - again, all i
> get is the filename - no path!
>
> 1) is gears just wrapping the browser's existing file input (in which
> case, it's not gears limiting access to the file path)?
> 2) if not, where in the source code for gears should i look to change
> this restriction?
>
> thanks,
> imran