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: 6
Registered: ‎03-05-2010
My Device: Bold 9700
My Carrier: ingénieur
Accepted Solution

problem with API FileI/O

I want to download an image and stored in the folder on the SD card, using the API File I / O.

 

its not work with blackberry.io.file.saveFile (filePath, blob);

 

Here is my code :

var filePath = "file:///store/home/user/myPicture/sample.png";

$.get(url, function(data) {

if(data != null) { blackberry.io.file.saveFile(filePath, data); }

alert("file saved");

},

'png');

 

I have this Exception :

java.lang.IllegalArgumentException: Invalid type - class java.lang.String Running at line 277:

 

blackberry.io.file.saveFile(filePath,data);.

 

help me plaiz

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: problem with API FileI/O

Is the data parameter you are passing in a Gears Blob?

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Highlighted
New Contributor
Posts: 6
Registered: ‎03-05-2010
My Device: Bold 9700
My Carrier: ingénieur

Re: problem with API FileI/O

I managed to solve the problem


I parsed the data into blob with gear api

 

    request.onreadystatechange = function(callback) {
        if (request.readyState == 4
                && (request.status == 200 || request.status == 0)) {

            if (request.responseBlob) {
                alert("request.Blob");
                blackberry.io.file.saveFile(filePath, request.responseBlob);
                alert("file saved");
            } else {
                alert("no request");
            }
        }
    };
    request.send(null);
}

Developer
Posts: 87
Registered: ‎02-26-2010
My Device: Bold 9000
My Carrier: Rogers

Re: problem with API FileI/O

Good work. I'll be sure to give this thread another look when I'm working on something similar!