I am using this file picker to upload files to my server:
https://github.com/jcesarmobile/FilePicker-Phonegap-iOS-Plugin
My server takes base64 files, so I need to convert the file I uploaded. I am doing that using the file plugin mentioned in the ionic docs. So my code looks like this:
uploadIOS(){
var self=this
let utis = ["public.data"]
FilePicker.pickFile(
function (uri) {
let correctPath = uri.substr(0, uri.lastIndexOf('/') + 1);
let currentName = uri.substring(uri.lastIndexOf('/') + 1);
self.file.readAsDataURL(correctPath, currentName).then(result=>{
console.log ('reading data ' + JSON.stringify(result))
}).catch((err)=>{
console.log ('err4' + JSON.stringify(err))
})
},
function (error) {
console.log(JSON.stringify(error));
},
function (utis) {
console.log('UTIS', this.utis)
}
)
}
but when I upload from Google Drive, or iCloud Drive or DropBox it returns
{"code":5,"message":"ENCODING_ERR"}
let self = this;
self.filePicker.pickFile().then(uri => {
let correctPath = uri.substr(0, uri.lastIndexOf('/') + 1);
let currentName = uri.substring(uri.lastIndexOf('/') + 1);
self.file.readAsDataURL("file:///" + correctPath, currentName).then(result=>{
})
I have fixed this issue using this code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With