Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Web and WebWorks Development

Reply
Developer
Levion
Posts: 133
Registered: ‎12-22-2010
My Carrier: Software Developer

File Dialog on Playbook

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

Please use plain text.
BlackBerry Development Advisor
twindsor
Posts: 536
Registered: ‎07-15-2008
My Carrier: Bell

Re: File Dialog on Playbook

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.

Tim Windsor
Application Development Consultant
Please use plain text.
Developer
Levion
Posts: 133
Registered: ‎12-22-2010
My Carrier: Software Developer

Re: File Dialog on Playbook


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

Please use plain text.
BlackBerry Development Advisor
twindsor
Posts: 536
Registered: ‎07-15-2008
My Carrier: Bell

Re: File Dialog on Playbook

Are you running in Ripple? I didn't get that result on the device.
Tim Windsor
Application Development Consultant
Please use plain text.
Developer
Levion
Posts: 133
Registered: ‎12-22-2010
My Carrier: Software Developer

Re: File Dialog on Playbook

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</rim:permit>
    <rim:permit>access_shared</rim:permit>
    <rim:permit>read_geolocation</rim:permit>
  </rim:permissions>

 

Please use plain text.
BlackBerry Development Advisor
twindsor
Posts: 536
Registered: ‎07-15-2008
My Carrier: Bell

Re: File Dialog on Playbook

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-APIs/tree/master/Tablet/TEMPLATE

 

 

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;
}

 

 

Tim Windsor
Application Development Consultant
Please use plain text.
New Developer
svzi
Posts: 34
Registered: ‎04-04-2012
My Carrier: German Provider

Re: File Dialog on Playbook

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

Please use plain text.
Developer
Levion
Posts: 133
Registered: ‎12-22-2010
My Carrier: Software Developer

Re: File Dialog on Playbook

I would send you my solution. Please PM me.

Please use plain text.
Developer
Levion
Posts: 133
Registered: ‎12-22-2010
My Carrier: Software Developer

Re: File Dialog on Playbook

I hosted my solution on GitHub.

Please use plain text.