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
aleksander
Posts: 8
Registered: ‎07-25-2012
My Device: 9300

Saving big images with stringToBlob

Hi,

 

I just develop an app that saves images using stringToBlob, it works fine but when i try to save images with size over 100kb it doesn't work, i read that the max size of string must be 512kb (OS 5.0) so i used splice() to make 2 or 3 srtings but how could i save the image?

 

Thanks in advance

Developer
kamal_nigam
Posts: 434
Registered: ‎07-23-2012
My Device: Blackberry 10

Re: Saving big images with stringToBlob

Use byte array for images.

Thanks
-------------------------------------------------------------------------------------
Press the Accept as solution Button when u got the Solution
Press Kudo to say thank to developer.
-------------------------------------------------------------------------------------.
New Contributor
aleksander
Posts: 8
Registered: ‎07-25-2012
My Device: 9300

Re: Saving big images with stringToBlob

Hi, 

 

I download the images as a byte array the convert to Base64 to use the stringToBlob function and finally use th saveFile function with the data converted, instead of converting to Base64 call the saveFile with the array??

Developer
kamal_nigam
Posts: 434
Registered: ‎07-23-2012
My Device: Blackberry 10

Re: Saving big images with stringToBlob

yes.

Thanks
-------------------------------------------------------------------------------------
Press the Accept as solution Button when u got the Solution
Press Kudo to say thank to developer.
-------------------------------------------------------------------------------------.
New Contributor
aleksander
Posts: 8
Registered: ‎07-25-2012
My Device: 9300

Re: Saving big images with stringToBlob

That did the trick, i can save big images...but i can't open it...
Developer
kamal_nigam
Posts: 434
Registered: ‎07-23-2012
My Device: Blackberry 10

Re: Saving big images with stringToBlob

what error u are getting ???

Thanks
-------------------------------------------------------------------------------------
Press the Accept as solution Button when u got the Solution
Press Kudo to say thank to developer.
-------------------------------------------------------------------------------------.
New Contributor
aleksander
Posts: 8
Registered: ‎07-25-2012
My Device: 9300

Re: Saving big images with stringToBlob

Hi, 

 

Actually i didn't get any error, but when i try to open the image i only see the default icon. Here is part of mi code  

 

function getBinary(url){
var request = new XMLHttpRequest();
request.open("GET", url, false);
request.overrideMimeType("text/plain; charset=x-user-defined");
request.send(null);

if(request.status == 200){
return request.responseText;
} else{
alert("REQUEST TEXT NULL");
return null;
}
}

 

function downloadHandler(_blob,_tempImgPath){
try{
var blobData = blackberry.utils.stringToBlob(_blob);
try{
blackberry.io.file.saveFile(_tempImgPath , blobData);
alert("Success downloading. saved in:\n" + _tempImgPath);
} catch(e){
alert("Error while saving the image!!\n" + e);
}
} catch(e){
alert("Error while converting the image!!\n" + e);
}
}

 

binaryText = getBinary(url);

downloadHandler(binaryText,tempImgPath);

 

And when i convert the "_blob" variable to Base64 instead of working with the byte array, i can open the images...

Trusted Contributor
NitishSubudhi
Posts: 166
Registered: ‎12-09-2011
My Device: 9550,9300,9800,9700,9900,9850,9860

Re: Saving big images with stringToBlob

Hi aleksander,

I was also facing the same problem but now I can download the images and storing the images inside the SD card and by giving the path I can extract the image from Sd card and show the image in APS

may be this link help u and you can find the answer of your problem:

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Download-Image-From-URL-Link-And... 

Thanks & Regards,
Nitish Subudhi

Feel Free To Press The Like Button On The Right Side To Thank The User That Helped You.
Please Mark Posts As Solved If You Found a Solution.