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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 93
Registered: ‎08-18-2011
My Device: 9550
My Carrier: At&T
Accepted Solution

How to write a file using BB 10 HTML5WebWorks

Hi,

 

How to write a file using Blackberry 10 HTML5WebWorks API.

 

https://developer.blackberry.com/html5/api/blackberry.io.file.html#.saveFile

 

The above example is not working in BB 10.

 

Please guide me.

 

 

Thanks,

Shwarup Biswas
Retired
Posts: 203
Registered: ‎12-18-2012
My Device: Z10, Q10, Q5, Z30, Z3
My Carrier: Bell

Re: How to write a file using BB 10 HTML5WebWorks

Hi,

 

You'll need to use the HTML5 file writer. The API you referenced is not supported by BB10.

 

https://developer.blackberry.com/html5/apis/filewriter.html

 

Thanks,

Bryan

Bryan Higgins
BlackBerry WebWorks
@bryanhiggins
Developer
Posts: 322
Registered: ‎08-06-2012
My Device: Dev Alpha / Playbook / Curve 9300

Re: How to write a file using BB 10 HTML5WebWorks

If its an image or camera pic taken then this worked for me...

 

Save Pic

 

I struggled to get HTML5 file writer to work - in fact it never did.  Not saying that it won't though.

If it helped you, click like. Smiley Happy
Developer
Posts: 93
Registered: ‎08-18-2011
My Device: 9550
My Carrier: At&T

Re: How to write a file using BB 10 HTML5WebWorks

Hi Bryan,

 

Any example using "HTML5 file writer" would be appreciated.

 

 

Thanks,

Shwarup Biswas
Retired
Posts: 203
Registered: ‎12-18-2012
My Device: Z10, Q10, Q5, Z30, Z3
My Carrier: Bell

Re: How to write a file using BB 10 HTML5WebWorks

Sure, look at line 95 of this file:

 

https://github.com/blackberry/BB10-WebWorks-Samples/blob/master/invoke/invoker/invocations.js

Bryan Higgins
BlackBerry WebWorks
@bryanhiggins
Highlighted
Developer
Posts: 93
Registered: ‎08-18-2011
My Device: 9550
My Carrier: At&T

Re: How to write a file using BB 10 HTML5WebWorks

hi Bryan,

 

Thank you so much for your quick reply and sample app.

 

I have a requirement where i need to send a POST request to server and server will return a whole HTML page string as response. I want to save this content in one of my workspace file say "href.html".

 

i implemented bellow code from your sample app :

 

function saveFileInvoke (post, url, data) {
    var xhr = new XMLHttpRequest();
    xhr.open(post, url, false);
    xhr.responseType = 'blob';

    xhr.onload = function(e) {
        blackberry.io.sandbox = false;
        window.webkitRequestFileSystem(PERSISTENT, 1024 * 1024, function(fs) {
            //fs.root.getFile(blackberry.io.sharedFolder + '/downloads/href.html', {create: true}, function(fileEntry) {
             fs.root.getFile('local:///href.html', {create: true}, function(fileEntry) {
                fileEntry.createWriter(function(writer) {

                writer.onerror = function(e) { alert(e) };

                var blob = new Blob([xhr.response], {type: 'text/html'});

                writer.write(blob);

                }, errorHandler);
            }, errorHandler);
        }, errorHandler);
    }

    xhr.send(data);

    blackberry.invoke.invoke({
        //uri: "file:///accounts/1000/shared/downloads/href.html",
        uri: "local:///href.html",
    }, onSuccess, onError);
}

 

but the page is not updating with the new content.

is this two line that i update with my local path is correct?

 

1. fs.root.getFile('local:///href.html', {create: true}, function(fileEntry) {

2. uri: "local:///href.html",

if not what should be path here.

Or am i missing something else.

 

Sorry for this basic question.

 

Thanks,

Shwarup Biswas