Hello…I’m used file plugin to write my zip file in my data.directory.I can get image uri format and convert to blob and try to write data directory. But i can’t able to write in folder, it’s working in iOS and Android emulator but it’s not working in Android device.I got this error.
{"type":"error","bubbles":false,"cancelBubble":false,"cancelable":false,"lengthComputable":false,"loaded":0,"total":0,"target":{"fileName":"","length":0,"localURL":"cdvfile://localhost/files/student.zip","position":0,"readyState":2,"result":null,"error":{},"onwritestart":null,"onprogress":null,"onwriteend":null,"onabort":null}}
saimon
February 23, 2018, 9:41am
2
Can you show your code how you actually save the file? At which point in the code do you exactly get this message?
I used this code for write my file
let body = response.text();
var bodyValue = response["_body"];
bodyValue = JSON.parse(bodyValue)
const bytes: string = atob(bodyValue['responseStatus']['image_uri']);
const byteNumbers = new Array(bytes.length);
for (let i = 0; i < bytes.length; i++) {
byteNumbers[i] = bytes.charCodeAt(i);
}
const byteArray = new Uint8Array(byteNumbers);
const blob: Blob = new Blob([byteArray], {
type: 'application/image'
});
const options = {
replace: true
}
this.file.writeFile(this.file.dataDirectory, 'sample.zip', blob, options)
.then(result => {
console.log('Success');
});
.catch(err => {
console.log('Error : ' + JSON.stringify(err));
});