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
Developer
Posts: 163
Registered: ‎05-06-2011
My Device: Playbook
My Carrier: Not Specified
Accepted Solution

WebWorks SDK v2.1.0 and File API

Hi,

 

First of all thanks for the update with new APIs. I need a clarification on File API. The below link on File API for playbook shows a few examples. http://www.blackberry.com/developers/docs/webworks/api/blackberry.io.file.html

This is an example used in the same page to write to an xml file.

 

var blob_data = blackberry.utils.documentToBlob(doc);



But I couldn't find this extension support under utils at http://www.blackberry.com/developers/docs/webworks/api/blackberry.utils.html. I suppose that is not enabled for Playbook for now. So, how do I create a file using Playbook File API.

 

 

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: WebWorks SDK v2.1.0 and File API

There is actually a glitch that went up with the API documents showing that read/save were supported in PlayBook.  These are not yet supported as we work though making Blob support work with the File API

 

We will be making these fixes to the API documents.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Developer
Posts: 163
Registered: ‎05-06-2011
My Device: Playbook
My Carrier: Not Specified

Re: WebWorks SDK v2.1.0 and File API

Hi Tim,

 

May I know what other features under IO API are available to be used by the playbook.

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: WebWorks SDK v2.1.0 and File API

Hi Praveen,

 

If you expand the "Supported Platform Table" at the top of the page it will show you what is all supported on each platform.  Problem is.. that we tagged the saveFile() and readFile() for support when they shouldn't be tagged.

 

http://www.blackberry.com/developers/docs/webworks/api/blackberry.io.file.html

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Developer
Posts: 163
Registered: ‎05-06-2011
My Device: Playbook
My Carrier: Not Specified

Re: WebWorks SDK v2.1.0 and File API

Hi Tim,

 

So the rest of FIle APIs like copy, delete, exist, open and getFileProperties should work right.

 

I'm having a custom extension to read and write to a file. I thought the new APIs could replace my custom ones  :smileysad: The problem I'm facing with my custom file API is I'm not able to save image data. I could write the raw image data into a file. But viewing the same doesn't show up the image. Any suggestions on this? So, until next release I'll have to use my custom extension :smileyhappy:



Developer
Posts: 163
Registered: ‎05-06-2011
My Device: Playbook
My Carrier: Not Specified

Re: WebWorks SDK v2.1.0 and File API

Hi TIm,

 

I did a small research on the File API extension. I could see the implementation of saveFile() and readFile() under extensions folder. The error I get when I try to save a file is Error #1034 and this I suppose this is the line (bbwp\ext\blackberry.io.file\src\Air\File\src\blackberry\io\file\FileExtension.as) that throws this error

 

var fileBlob:IWebWorksData = blobService.execute("getBlob", { id : blobId }).data;

 Could you please confirm what is causing this error. Is there some work around this until the next release comes up?

 

Developer
Posts: 163
Registered: ‎05-06-2011
My Device: Playbook
My Carrier: Not Specified

Re: WebWorks SDK v2.1.0 and File API

Hi TIm,

 

An update on this, the saveFile() and readFile() APIs are working correctly. This is how i tested them.

 

var path = 'file:///accounts/1000/shared/downloads/readme.txt';
blackberry.io.file.readFile(path,  handleOpenedFile);

function handleOpenedFile(fullPath, blobData) {
   var filepath = 'file:///accounts/1000/shared/downloads/test.txt';
   blackberry.io.file.saveFile(filepath,  blobData);
}

First i got the blob data of a sample file using readFile() and gave the same as an input to saveFile() API. I was then able to create a copy of the first file. So the issue I think that exist is converting a string or binary data into blob data. Am I correct? So I guess i partially solved the problem myself :smileyhappy:

 

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: WebWorks SDK v2.1.0 and File API

Yes, the implementation of the saveFile() and readFile() are there under the covers.  The issue is that all you can do is read a file in and then write it back out.  Essentially a copy().  

 

One of the main drivers around the read/save functions are to read in and manipulate the data from the read by being able to do the blobToString() which isn't supported yet on PlayBook, and save via stringToBlob() which also isn't yet supported.

 

Since these are the main use case scenarios for save/read, it is the reasoning why we are marking these methods as not supported on the PlayBook.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Developer
Posts: 817
Registered: ‎11-19-2009
My Device: Z10, Q10, 9900, 9790, PlayBook,
My Carrier: T-Mobile UK, Three, O2, Orange, Sunrise, Swisscom

Re: WebWorks SDK v2.1.0 and File API

Is there any ETA for the PlayBook implementation?

--
Olivier - interfaSys ltd
Developing for BlackBerry 10 devices using the Sencha Touch framework.
Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: WebWorks SDK v2.1.0 and File API

I don't have one at the moment.  

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter