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
asiayeah
Posts: 123
Registered: ‎11-05-2011
My Device: Z10, Bold 9900

Can I read from a blob byte by byte?

On a playbook, I am trying to use the blackberry.io.file API to open a local file. From the blob, what is the correct way to read the binary file byte by byte?

 

I know there is the blogToString API, but does it work with binary file?

 

Thanks!

Retired
jeffheifetz
Posts: 518
Registered: ‎07-18-2011
My Device: Bold

Re: Can I read from a blob byte by byte?

Hi asiayeah,

 

The Blob interface has a "getBytes" method, but I've never used it.

 

I have documented the missing Blob documentation here



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)
Developer
asiayeah
Posts: 123
Registered: ‎11-05-2011
My Device: Z10, Bold 9900

Re: Can I read from a blob byte by byte?

Thanks, jeffheifetz.

 

I have clicked on the link you posted, but I only find the issue with no documentation. Do you mean you are going to create one?


I have looked at https://github.com/blackberry/WebWorks-TabletOS/blob/master/js_api/globalJS/5_blob.js, but I can't see the "getBytes" method there though. Any idea why?

 

Thank you.

Contributor
cuixu66
Posts: 21
Registered: ‎12-25-2011
My Device: Playbook

Re: Can I read from a blob byte by byte?

Hello Jeff,

I think I need to use the "getBytes" method on blob on PLAYBOOK.(If it exists).

The "blob documentation" link has no useful information right now.

Could you please give me a new link with blob interface available on playbook webworks?

Thanks!
Retired
jeffheifetz
Posts: 518
Registered: ‎07-18-2011
My Device: Bold

Re: Can I read from a blob byte by byte?

As I stated earlier, the getBytes method is not currently in our documentation, the link is to an issue to track this so that it will be fixed at some point.

 

Here is a link to the gears Blob which I believe should match the implementation on the smartphone (atleast in 5.0). I do not know if this method is implemented on the playbook, best way is try and see.



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)
Contributor
cuixu66
Posts: 21
Registered: ‎12-25-2011
My Device: Playbook

Re: Can I read from a blob byte by byte?

Thank Jeff,

Also,

For those interested to know:
The blob.getBytes is not implemented on playbook.
Developer
asiayeah
Posts: 123
Registered: ‎11-05-2011
My Device: Z10, Bold 9900

Re: Can I read from a blob byte by byte?

Actually the blob.getBytes is available on both PlayBook and BlackBerry smartphone platform. I am able to use it in my PlayBook app.

Developer
ignites
Posts: 466
Registered: ‎04-11-2012
My Device: Bold 9900

Re: Can I read from a blob byte by byte?

Not sure if this is what you want but you can also put your blob in a string then read it through 1 index at a time
ie.
var strName = blob;
strName[i] would read the i-th character.


Developer for easyDial for BlackBerry Bold & inLink for BlackBerry PlayBook
Find me online via twitter, or on the techfruits.com webpage. Please hit the like button below if what I said helped!
Developer
asiayeah
Posts: 123
Registered: ‎11-05-2011
My Device: Z10, Bold 9900

Re: Can I read from a blob byte by byte?

[ Edited ]

Have RIM updated the missing documentation for the Blob yet?

 

I've been using the Blob.getBytes(). However, I found that it is leaking memory each time, getBytes() is called, even after releasing the returned byte[]. Is it a known issue? Is there any other workaround?

 

I'm testing on PlayBook 2.0.1.

 

Thanks.