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
Contributor
Posts: 19
Registered: ‎12-26-2010
My Device: 9800

Re: stringToblog save image problem

final_image_blob = blackberry.utils.stringToBlob(data,"BASE64");
fileDir = "file:///store/home/user/camera";
//blackberry.io.dir.createNewDir(fileDir);
try {
blackberry.io.file.saveFile(fileDir + "/test.jpeg", final_image_blob);
} catch (e) {
alert('e.message = ' + e.message);
}

 

This shall do it for you

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

Re: stringToblog save image problem

In WebWorks for the java smartphone, it looks like the base64 encoding works by decoding the Base64 (opposite of the TabletOS version).

 

You need to save it as a binary file if you are going to use it in other applications.

 

Have you tried converting the base64 content with another base64 converter to compare the results?

Tim Windsor
Open Source Technical Lead
New Contributor
Posts: 8
Registered: ‎07-25-2012
My Device: 9300
My Carrier: iusacell

Re: stringToblog save image problem

Hi,

Thanks for the code, i already solved.

 

This "request.overrideMimeType("text/plain; charset=x-user-defined");" download the image as binary then convert the responseText to base64 and use stringToBlob.

 

Finally just one more question... i´d saved small images but when i try to save a 213kb or 404kb image...doesn't work does anybody know why??

Contributor
Posts: 12
Registered: ‎10-13-2012
My Device: Playbook
My Carrier: Comcast (WiFi)

Re: stringToblog save image problem

Is this supposed to work for jpeg files as well?  I could get it to work for .png files but not .jpg files

 

ie:

var currentImgData = currentCanvas.toDataURL("file/jpeg");
currentImgData = currentImgData.replace('data:image/jpeg;base64,', '');
var currentBlobData = blackberry.utils.stringToBlob(currentImgData, 'binary');

 -Jacquie