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.

inside custom component

Native Development

Reply
Trusted Contributor
Mitch99
Posts: 102
Registered: ‎05-09-2013
My Device: BB10 Z10

Re: Access to app's working directory

[ Edited ]

Actually, I get that fully qualified path using the method I specified in the initial post, and that doesn't work. It is something to do with Ajax Jquery, having that path within the HTML file, not in the QML file...

 

Can you try passing that path into an HTML file and fetching it form within it? that would be the true test...

Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Access to app's working directory

LOL, back to square one!

Can you check first with the full path hard wired in to the WebView?

Then the next step is to send the path to the console to see if it matches/

If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Access to app's working directory

[ Edited ]

I may be wrong, but I think WebView process runs as another user and doesn't have direct access to application data folder. Otherwise it would be too easy to access user data by visiting a malicious web page. You could try navigating to file://. to check which files it has access to:

WebView {
  url: "file://."
}

In case the file is inaccessible, the data can probably be transferred using WebView's postMessage().

 


Andrey Fidrya, @zmeyc on twitter
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Access to app's working directory

@zmey that's what I thought at first but it proves not to be the case, now the question is whether within the web page you can access these folders if the OP is to be believed then assets can be accessed but not data even within a fully qualified path.

 

I had a piece of HTML5 code I thought I could use to test loading data within a html file but it doesn't work, the HTML5 files api is not supported within WebView. Also useful to know.

 

So I'm writing a JavaScript function within the webpage to test now.

 

However I think I already know what the answer will be, local and file are treated seperately from a permission point of view. And I can understand the reasons for this if true.

 

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Access to app's working directory

[ Edited ]

@Mitch99,

 

Okay I decided to keep it simple and used iframes instead and it is indeed true that local is treated differently from file within the web page.

 

So given that the data folder cannot be accessed using local: and file: is only allowed to access shared folders from within a web page then the only solution is to write your XML file to a shared folder or access it within the app instead.

 

From a security point of view this makes a lot of sense and really is the only way it could go but good to prove it.

 

[Edit] Sorry it took so long, I went off on a tangent with HTML5 Files api before considering using iframes to test it. Although it's probably not the answer you wanted at least you and I can understand why it is happening now.

 

 

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Trusted Contributor
Mitch99
Posts: 102
Registered: ‎05-09-2013
My Device: BB10 Z10

Re: Access to app's working directory

Okay, so writing to a shared folder... I can live with that. Thank you very much, I appreciated the help, and we learned quite a bit as well!

Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Access to app's working directory

Just don't forget to delete it after use (probably on app shutdown I would think) so the users folders are not filled with xml files.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Trusted Contributor
Mitch99
Posts: 102
Registered: ‎05-09-2013
My Device: BB10 Z10

Re: Access to app's working directory

[ Edited ]

An update: I've implemented writing to shared folder, actually, shared/misc folder, for now. File writes fine, it is there, everything checks out, and guess what... HTML DOES NOT see it! I've used

 

url: "../../../../../../shared/misc/graphData.xml",

 

right within JS, and no loading is happening. I've tested various "amounts" :smileyvery-happy: of "../" just to make sure I didn't miscount, all with the same result - JS does not see the file or load any data.

 

So - I then resorted to writing to the home directory of JS, "assets/charts", and since the files are now in the same directory, and using url: "graphData.xml", it finally WORKS! So - given this, I think there's something in JS that is not friendly to relative paths and path re-directions. This solution works for me, so I'll keep it as is.

Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Access to app's working directory

[ Edited ]

I think you are better off marking this one as solved and starting a new thread (referencing this one if you like) as not many will bother to read though this long thread just to reach another question.

 

Generally you should try and stick to one issue per thread that way people coming along later can search on the issue and (hopefully) see a resolution.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Trusted Contributor
Mitch99
Posts: 102
Registered: ‎05-09-2013
My Device: BB10 Z10

Re: Access to app's working directory

Will do, thanks! I keep forgetting that...