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: 5
Registered: ‎09-15-2011
My Device: Playbook
My Carrier: Vodacom

Blob to string error

Hello 

I am trying to convert a file to a Stringcurrently i open the file 

blackberry.io.file.readFile(filePath, readFile);

and tell it to pass the data to a readFile function 

 

function readFile(filePath, data) {

try
{
alert("Start of request");
var fileAsBase64String = blackberry.utils.blobToString(data);
$.ajax({
type: "POST",
url: "http://192.168.0.2/fileUpload/?id=1",
data: "type=picture&data="+fileAsBase64String
}).done(function( msg ) {
alert( "Data Saved: " + msg );
});
}catch(e) {
alert("Error " + e);
}

}

 

But i keep on getting the following error when i try and convert it to a String/base64string:

TypeError: Result of expression 'blackberry.utils.blobToString' [undifined] is not a function.

 

and this is my config file:

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" version="0.0.0.6">
<name>XXXXXXXXXXXXXXX</name>
<content src="index.html"/>
<icon src="icon.png"/>
<rimSmiley Surprisedrientation mode="landscape" />
<access uri="http://XXXXXXXXXXX"/>
<access uri="http://192.168.0.2"/>
<feature id="blackberry.system" />
<feature id="blackberry.media.camera" />
<feature id="blackberry.ui.dialog" />
<feature id="blackberry.io.dir" />
<feature id="blackberry.io.file" />
<feature id="blackberry.utils"  />
<author>XXX</author>
<authorid>XXXXXXXXXXXXXXXXXXXXXXXXX</authorid>
<rimSmiley Tongueermissions>
<rimSmiley Tongueermit>use_camera</rimSmiley Tongueermit>
<rimSmiley Tongueermit>access_shared</rimSmiley Tongueermit>
</rimSmiley Tongueermissions>
</widget>

 

anyone know what i am doing wrong?

The file does exsit but as soon as i try and convert it i get this error.

I am testing this on my blackberry playbook.

The SDK i am using is BlackBerry WebWorks SDK for TabletOS 2.1.0.6

New Contributor
Posts: 5
Registered: ‎09-15-2011
My Device: Playbook
My Carrier: Vodacom

Re: Blob to string error

Found out my SDK did not include it... i needed 2.2 was running the 2.1.6 SDK for tablet os webworks lol 

 

The blackberry.utils API now includes support for blobToString and stringToBlob functions.