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
Regular Contributor
Posts: 63
Registered: ‎06-08-2012
My Device: BlackBerry
My Carrier: BlackBerry

Issue about saveFile (image)

Hi everyone,

 

I try to get Image from server and save to Playbook.

But It do not something!

Could you show me the reason?

 

My code:

 

try {
var _now = new Date();
var fileName = 'IMG_0123456789';
var dirs = blackberry.io.dir.appDirs;
var image_path = dirs.shared.camera.path+'/Rs'+fileName+'.png';

var image01 = document.createElement('img');
var myCanvas = document.createElement("canvas");
var mycanvas_context;

image01.onload = function() {
myCanvas.width = image01.width;
myCanvas.height = image01.height;
mycanvas_context = myCanvas.getContext("2d");

mycanvas_context.drawImage(image01,0,0);

final_image = myCanvas.toDataURL("image/png");

final_image_blob = blackberry.utils.stringToBlob(final_image,"BASE64");
blackberry.io.file.saveFile(image_path, final_image_blob);
};
image01.src='http://cdn.sheknows.com/articles/2012/02/Sarah_Parenting/baby-names-baby-in-towel2.jpg';


} catch(e) {
alert("Err. "+e);
}

 

See your response soon! 

 

Regards,

An Pham

Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Issue about saveFile (image)

Hi,

 

have a closer look at the Upload/Download API for FileTransfer from the WebWorks Community API repository. I'm working with it to download files from a server and store them on the PlayBook and it works very well until now.

 

Regards.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Developer
Posts: 314
Registered: ‎03-28-2012
My Device: Curve 9360, Playbook, BB10 Dev Alpha
My Carrier: TMN

Re: Issue about saveFile (image)

Do you have the proper permissions set in your config.xml file?

Nuno
Regular Contributor
Posts: 63
Registered: ‎06-08-2012
My Device: BlackBerry
My Carrier: BlackBerry

Re: Issue about saveFile (image)

Thanks your quick reply ^^

Since I don't see example, so I don't understand. hixhix
Do you have other example?
Regular Contributor
Posts: 63
Registered: ‎06-08-2012
My Device: BlackBerry
My Carrier: BlackBerry

Re: Issue about saveFile (image)

Hi nunodonato,

Yes, I have


<rimSmiley Tongueermissions>
<rimSmiley Tongueermit>access_shared</rimSmiley Tongueermit>
</rimSmiley Tongueermissions>
Developer
Posts: 314
Registered: ‎03-28-2012
My Device: Curve 9360, Playbook, BB10 Dev Alpha
My Carrier: TMN

Re: Issue about saveFile (image)

can you post your entire config.xml please?

Nuno
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Issue about saveFile (image)


hoangan_it wrote:
Thanks your quick reply ^^

Since I don't see example, so I don't understand. hixhix
Do you have other example?

There is an example on the page that should work very well. See the "Code Example" source code for a starting point to get it working.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Regular Contributor
Posts: 63
Registered: ‎06-08-2012
My Device: BlackBerry
My Carrier: BlackBerry

Re: Issue about saveFile (image)

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" id="abc" version="1.0.0.0">
<name>MyAppExample</name>
<description>RightStar</description>
<author email="phan@tma.com.vn">An Pham</author>
<feature id="blackberry.identity" required="true" version="1.0.0.0"/>
<feature id="blackberry.message" required="true" version="1.0.0.0"/>
<feature id="blackberry.io.dir" required="true" version="1.0.0.0"/>
<feature id="blackberry.io.file" required="true" version="1.0.0.0"/>
<feature id="blackberry.invoke.CameraArguments" required="true" version="1.0.0.0"/>
<feature id="blackberry.media.camera"/>
<feature id="blackberry.find" required="true" version="1.0.0.0"/>
<feature id="blackberry.app" required="true" version="1.0.0.0"/>


<feature id="blackberry.system" />
<feature id="blackberry.connection" />
<feature id="blackberry.invoke"/>
<feature id="blackberry.utils" />

<feature id="blackberry.app.event"/>



<icon rim:hover="false" src="WebContent/images/app_logo.png"/>
<icon rim:hover="true" src="WebContent/images/app_logo.png"/>

<content src="login.html">

</content>

<rimSmiley Surprisedrientation mode="landscape" />


<rim:loadingScreen backgroundColor="#063a6b"
onFirstLaunch="true"
onRemotePageLaunch="true"
onLocalPageLoad = "true">
<rim:transitionEffect type="zoomIn" direction="slideOver" duration="1000"/>
</rim:loadingScreen>


<rimSmiley Tongueermissions>
<rim: permit>access_shared</rim: permit>
<rim: permit>read_geolocation</rim: permit>
<rim: permit>use_camera</rim: permit>
</rim: permissions>

</widget>
Developer
Posts: 314
Registered: ‎03-28-2012
My Device: Curve 9360, Playbook, BB10 Dev Alpha
My Carrier: TMN

Re: Issue about saveFile (image)

You are missing specific access permissions for the folders you are trying to access.

check this post: http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Cannot-read-file-from-shared-fol...

Nuno
Regular Contributor
Posts: 63
Registered: ‎06-08-2012
My Device: BlackBerry
My Carrier: BlackBerry

Re: Issue about saveFile (image)

Hi nunodonato,

I see and you are not yet show solutions!
Because I develop for playbook

Would you mind to show me your solution?

Regards,