-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
writeFile issues in alternate file implementation. #439
Comments
@rapropos can you help us here if you have some time? |
opts variable is declared, but not initialised, so when replaceOrOptions as boolean is passed, the replace property is being set on opts (that does not exist). See line 672 and 675 in https://github.com/driftyco/ionic-native/blob/master/src/plugins/file.ts |
I am testing the new release with fixes of #468:
Still returning:
So, I create an empty file before:
And it works, creates a file and replace it with the content. Should writeFile create the file if does not exist? Or is this the expected behavior? |
I have doubts about that too, because I follow the same procedure @rapropos can you help us here if you have some time ;). |
Related #464 |
Can you try with the latest version v2.2.2 and report back if you still have any issue? Thanks. |
I'm sorry if this is a stupid question, but why does this don't work ? let imageSrcData = 'data:image/jpeg;base64,' +base64PictureData;
let blob = this.b64toBlob(imageSrcData);
let fileName = this.globalState.username + "-" + Date.now()+".jpg";
let directory = this.file.dataDirectory+"/takenPictures";
let fullImagePath = directory + "" + fileName;
console.log(blob.size/1024 + "kB");
console.log(directory);
console.log(fileName);
let options:WriteOptions = {};
this.file.writeFile(directory,fileName, blob, options).then((res:any)=>{
console.log("DONE WRITING");
console.log(res);
try{
this.navCtrl.push(EditImagePage,{results:fullImagePath});
}catch(error){
alert("setonPictaken Error: "+ error);
}
},(error)=>{
console.error("Error while saving image");
console.log(error);
}); the blob object is fine, the path and the filename are fine. But this function won't call success or error. it just does nothing. Even if I set the WriteOptions it don't work. can somebody help me ?
|
@hartherbert same problem this function won't call success or error |
I little time passed since last comment, but |
I am trying to save a blob in the external memory of device. I was rewriting from old ngCordova code with $cordovaFile and $cordovaFileOpener2 plugins. It correctly worked in Ionic 1 app. Now, with new methods of File implemented by (#283) (6ed32ef) I am trying to do using writeFile in the same app, but seems there is an issue with options parameter:
But get an error:
OK, maybe boolean is failing, I try passing an option object:
But another error throw:
OK, I will add append to object, but again same error (seems opts is not defined, but should be).
Let's do some hacking. I changed
var opts
withvar opts = {}
and try... but:Finally, I try create first an empty file, and then overwrite its content:
But got:
Some info:
The text was updated successfully, but these errors were encountered: