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
Trusted Contributor
Posts: 118
Registered: ‎03-06-2013
My Device: Blackberry Z10
My Carrier: Airtel
Accepted Solution

LocalFileSystem problem in BB10

Hello ,

 

I am using following Async API for accessing data from a image file and then writing it on to temporary file system of application , so that i can access the same afterwards:

 

window.requestFileSystem(
LocalFileSystem.TEMPORARY,
0,
// Success Callback
onPhotoWriterFileSystemReady,
// Failure Callback
failureCallback);

// Local file writer for imagedata
// It writes image as a text file: userpic.txt
function onPhotoWriterFileSystemReady(fileSystem) {
fileSystem.root.getFile(
imageFilename,
{create: true},
// Success Callback
onPhotoWriterFileEntryReady,
// Failure Callback
errorCallback);


// Enters into file and intializes writer for writing onto file.
function onPhotoWriterFileEntryReady(fileEntry) {
fileEntry.createWriter(
// Success Callback
onPhotoWriterFileWriterReady,
// Failure Callback
failureCallback);

// Writes base64 data onto local file.
function onPhotoWriterFileWriterReady(writer) {
writer.onwrite = function(evt) {
setPhotoToDiv(pictureDataBase64);
};

 writer.write(pictureDataBase64);
}
}
}

 

the above code fails at writer.onwrite()(means write operation is unsuccessful), when i install the application and launch it for the first time. but on subsequent launches write is successful.

why is this difference? what is the work around that i can use to avoid this kind of problem in my application, please suggest me.

--------
- If a post contains the solution to the problem, please click "Accept as Solution"
- If a post contains helpful content, please give it a "Thumbs Up"

developer.blackberry.com
@BlackBerryDev
Trusted Contributor
Posts: 118
Registered: ‎03-06-2013
My Device: Blackberry Z10
My Carrier: Airtel

Re: LocalFileSystem problem in BB10

if anyone has any idea please let me know.i need this to make it work
--------
- If a post contains the solution to the problem, please click "Accept as Solution"
- If a post contains helpful content, please give it a "Thumbs Up"

developer.blackberry.com
@BlackBerryDev
Retired
Posts: 165
Registered: ‎09-24-2012
My Device: Passport
My Carrier: Bell

Re: LocalFileSystem problem in BB10

Hi lathajagan,

 

I noticed you pass 0 as the size when calling requestFileSystem(). This may be why the write fails (this will typically throw a QUOTA_EXCEEDED error).

 

Try the following: 

requestFileSystem(TEMPORARY,1024*1024,success,error)

 

Trusted Contributor
Posts: 118
Registered: ‎03-06-2013
My Device: Blackberry Z10
My Carrier: Airtel

Re: LocalFileSystem problem in BB10

amazing , this worked fine for me without any problem, thanks a lot.
now i know how amazing it is to solve someone's problem very quickly.
--------
- If a post contains the solution to the problem, please click "Accept as Solution"
- If a post contains helpful content, please give it a "Thumbs Up"

developer.blackberry.com
@BlackBerryDev
Trusted Contributor
Posts: 118
Registered: ‎03-06-2013
My Device: Blackberry Z10
My Carrier: Airtel

Re: LocalFileSystem problem in BB10

@anzor_b, one more help needed from your side, i am reading and writing the picture into the file system many times continuously, then the quality of the picture read is very bad, any idea how to solve it?
--------
- If a post contains the solution to the problem, please click "Accept as Solution"
- If a post contains helpful content, please give it a "Thumbs Up"

developer.blackberry.com
@BlackBerryDev
Retired
Posts: 165
Registered: ‎09-24-2012
My Device: Passport
My Carrier: Bell

Re: LocalFileSystem problem in BB10

Hi lathajagan,

 

As long as you read the file as a byte array and write the same bytes back to the filesystem, quality should not change. How do you read and write it? 

Trusted Contributor
Posts: 118
Registered: ‎03-06-2013
My Device: Blackberry Z10
My Carrier: Airtel

Re: LocalFileSystem problem in BB10

hello anzor_b,
i have solved the quality problem in bb10 already, problem was i am trying to read 1.75MB file but have requested for only 1MB, which is reducing the quality.
from phonegap API i get a URL and write this URL on file system and then read the same as byte array.
i work on cross platform application which works on andriod and IOS too apart from blackberry, there the quality is still very low. i tired same solution as increasing the amount of memory requested from file system it didnt help. any ideas abt this?
--------
- If a post contains the solution to the problem, please click "Accept as Solution"
- If a post contains helpful content, please give it a "Thumbs Up"

developer.blackberry.com
@BlackBerryDev
Retired
Posts: 165
Registered: ‎09-24-2012
My Device: Passport
My Carrier: Bell

Re: LocalFileSystem problem in BB10

Sorry, I didn't quite catch your response. You mention that "i have solved the quality problem in bb10 already", but from the sounds of it you still have the quality issue on BB10. Is this correct?

Trusted Contributor
Posts: 118
Registered: ‎03-06-2013
My Device: Blackberry Z10
My Carrier: Airtel

Re: LocalFileSystem problem in BB10

@anzor_b, yes, i tried solving the issue by increasing the memory i am requesting from file system to something more, but in Q10 i am using the same logic as Z10, issue is still exisiting, can u tell me if this is the correct way of solving the problem?
--------
- If a post contains the solution to the problem, please click "Accept as Solution"
- If a post contains helpful content, please give it a "Thumbs Up"

developer.blackberry.com
@BlackBerryDev
Retired
Posts: 165
Registered: ‎09-24-2012
My Device: Passport
My Carrier: Bell

Re: LocalFileSystem problem in BB10

@lathajagan,

 

The logic should be the same on Q10 and Z10. Can you give me an example of the images before and after saving so I can see what you mean by "quality"? Thanks.