03-15-2012 08:34 AM
Hi,
I want to let my user save and read data from playbook. I am suprised that this is a hard challenge in WebWorks but I can't find a good solution.
The best I found was to generate a <input type="file" ... field and make it invisible (by opacity). I trigger the field in my button event. After the "onchange" of the file input is triggered I get a "C:\fakepath\<filename>". But what's this? I can't work that!
Is there a good way to let my user select a file?
best regards
03-16-2012 05:22 PM
I'd say that's a clever way to get a file dialog without showing the user the usual file input method. What's wrong with getting the path that way? You can open the file and read or write data to it at that point.
03-17-2012 04:27 AM
twindsor wrote:
What's wrong with getting the path that way?
I'm getting only "C:\fakepath\..." NOT the real path. I can't use this for file IO.
It seems there is a protection to do it in this way.
regards
03-17-2012 11:55 AM
03-17-2012 12:35 PM
No, I get this on device (OS 2.0). It's started it in developer mode (with debug token).
This is my set of features from config.xml:
<feature id="blackberry.system" required="true" version="1.0.0.0" /> <feature id="phonegap" required="true" version="1.0.0" /> <feature id="blackberry.find" required="true" version="1.0.0.0" /> <feature id="blackberry.identity" required="true" version="1.0.0.0" /> <feature id="blackberry.pim.Address" required="true" version="1.0.0.0" /> <feature id="blackberry.pim.Contact" required="true" version="1.0.0.0" /> <feature id="blackberry.io.file" required="true" version="1.0.0.0" /> <feature id="blackberry.utils" required="true" version="1.0.0.0" /> <feature id="blackberry.io.dir" required="true" version="1.0.0.0" /> <feature id="blackberry.app" required="true" version="1.0.0.0" /> <feature id="blackberry.app.event" required="true" version="1.0.0.0" /> <feature id="blackberry.system.event" required="true" version="1.0.0.0"/> <feature id="blackberry.media.camera" />
This is me set of permissions from config.xml:
<rim:permissions>
<rim:permit>use_camera</rim:permit>
<rim:permit>read_device_identifying_information</r im:permit>
<rim:permit>access_shared</rim:permit>
<rim:permit>read_geolocation</rim:permit>
</rim:permissions>
03-21-2012 04:48 PM
I've reproduced this and it looks like a silly shortcut has been taken. Since the input is "technically" for uploading a file, someone must have decided not to include the full path and instead use this shortcut. I've gotten the same results on BlackBerry 7.1.0 and 2.0, so it's consistent within our webkit browsers.
I've submitted an issue against both the smartphone and PlayBook to see if we can get this fixed, because it would be a nice simple way to have a native file browser.
However, in the meantime you could make a WebWorks extension in AIR in no time. Start with the extension template here: https://github.com/astanley/WebWorks-Community-API
And the AIR API you need is File.browseForOpen():
private var file:File;
private var path:String;
private function chooseFile():void {
file = new File();
file.addEventListener(Event.SELECT, file_select);
file.browseForOpen("Please select a file...");
}
private function file_select(evt:Event):void {
path = File(evt.currentTarget).nativePath;
}
06-23-2012 08:05 AM
An news on this topic?
The issue still exists in OS 2.1, which is very disappointing for me. Must I really write my own AIR plugin to be able to select the right path? I never did anything in AIR before and I would really appreciate if someone could provide the ready-to-use plugin (maybe via a public github repository)...
Cheers,
Sven
06-24-2012 10:50 AM
I would send you my solution. Please PM me.
02-18-2013 02:56 AM
I hosted my solution on GitHub.