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: 2
Registered: ‎02-15-2014
My Device: z10
My Carrier: o2
Accepted Solution

Writing a file with the file system

I'm trying to export a file in javascript and write it to non-volatile storage.

 

I'm using WebWorks 2 (BB10.2) and the "com.blackberry.io" plugin.

 

I'm able to access the file system

 

window.requestFileSystem(window.PERSISTENT, 0, function (fileSystem) {
fileSystem.root.getFile(sFile, { create: true }, function (fileEntry) {
console.log("Cordova about to create writer from file entry");

 

//console.log(JSON.stringify(fileEntry));
fileEntry.createWriter(function (writer) {
console.log("Cordova about to write to file");

 

writer.onwrite = function (evt) {
console.log("Write success: " + fileEntry.fullPath);
alert(fileEntry.fullPath);
};

 

 

 

 

BlackBerry Development Advisor
Posts: 635
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: Writing a file with the file system

Have you taken a look at the canvasToFilesystem sample app?

 

While you may not be trying to save canvas data, it will still show you how to access the filesystem and save data using WebWorks 2.0 and the com.blackberry.io plugin.

 

https://github.com/blackberry/BB10-WebWorks-Samples/tree/WebWorks-2.0/canvasToFilesystem

New Contributor
Posts: 2
Registered: ‎02-15-2014
My Device: z10
My Carrier: o2

Re: Writing a file with the file system

[ Edited ]

I'm sorry my original post has seemed to be cut short. 

The problem was when actually calling:

writer.write(new Blob([sData], { type: "text/csv;charset=utf-8" }));

 

I've also since discovered what was causing the issue. The debugger on the pc seems to interfere with the process. As soon as I removed the breakpoints it started working.

BlackBerry Development Advisor
Posts: 635
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: Writing a file with the file system

Great! Thanks for the update.