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

Web and WebWorks Development

Reply
New Contributor
Posts: 9
Registered: ‎08-09-2013
My Device: BlackBerry Z10
My Carrier: Proximus
Accepted Solution

BB10 + Phonegap 3.0.0 + FileTransfer

Hi,

 

I'm developing an app with Phonegap 3.0.0 and have a question regarding FileTransfer.

 

When the app loads, it checks for new files and downloads them. The downloaded files then need to be stored locally.

I get the filesystem like this:

 

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, error);

 

After that I get the file and perform the filetransfer. The files are stored in the root path: local:///persistent/

The problem is that I don't have been able to show the files in an <img> tag, since I haven't figured out where the files actually are or how to get them. I tried local:///persistent/filename and file:///persistent/filename and none of them work, I even tried /filename.

 

Do I have to save the files in another way to be able to use them in an <img> tag?

Suggestions?

 

Thanks!

Retired
Posts: 856
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: BB10 + Phonegap 3.0.0 + FileTransfer

I haven't used the filesystem through a PhoneGap app yet, but a path in the filesystem doesn't normally look like that on BB10. I also think you need to request a size, not 0 in that call.

 

I'd suggest including the blackberry.io plugin and then following an example from here: 

https://developer.blackberry.com/html5/apis/blackberry.io.html

Tim Windsor
Open Source Technical Lead
Retired
Posts: 6
Registered: ‎10-08-2012
My Device: developer
My Carrier: Telus

Re: BB10 + Phonegap 3.0.0 + FileTransfer

Hi, I think you are looking for something like this: http://www.html5rocks.com/en/tutorials/file/xhr2/#toc-reponseTypeBlob

New Contributor
Posts: 9
Registered: ‎08-09-2013
My Device: BlackBerry Z10
My Carrier: Proximus

Re: BB10 + Phonegap 3.0.0 + FileTransfer

Thx for your reply!

Well, I have made some adjustments and got the plugins working, but I'm getting permission errors (I think).

 

Access_shared is permitted.

blackberry.io.sandbox = false;

 

I tried two different solutions:

 

---- 1 ----

window.requestFileSystem  = window.requestFileSystem || window.webkitRequestFileSystem;

window.requestFileSystem(LocalFileSystem.PERSISTENT, 1024 * 1024, gotFS, error);

 

In gotFS: 

For fileSystem.root.fullPath it returns local:///persistent/

 

fileSystem.root.getFile(blackberry.io.sharedFolder + "/downloads/" + path, {create: true, exclusive: true}, gotFileEntry, errorHandler);

 

This returns an error with code 6.

 

 

---- 2 ----

Used blackberry.io.filetransfer.download to the same path, but this returns an error with code 4 with target: 

/accounts/1000/appdata/default.app.id.testDev_ault_app_id417e7455/data/../shared/downloads/talk-1253.jpg

 

 

Anyone has some suggestions here?

Thx!

New Contributor
Posts: 9
Registered: ‎08-09-2013
My Device: BlackBerry Z10
My Carrier: Proximus

Re: BB10 + Phonegap 3.0.0 + FileTransfer

Hi,

 

I solved it, sort of. I used home instead of sharedFolder and it worked!

 

Thx for all the help!