Madhi
June 20, 2017, 2:13pm
1
When i try to upload a photo from library i able to select a photo from library…but when it time to upload it shows a run time error
plugin_not_installed
here my code
this.camera.getPicture(options).then((imagePath)=>{
//toast controller
this.loading = this.loadingctrl.create({
content:'Please Wait..',
});
this.loading.present();
if(this.platform.is('android') && sourceType === this.camera.PictureSourceType.PHOTOLIBRARY){
this.filePath.resolveNativePath(imagePath)
.then(filePath => {
let correctPath = filePath.substr(0, filePath.lastIndexOf('/') + 1);
let currentName = imagePath.substring(imagePath.lastIndexOf('/') + 1, imagePath.lastIndexOf('?'));
is.copyFileToLocalDir(correctPath, currentName, this.createFileName());
});
} else {
var currentName = imagePath.substr(imagePath.lastIndexOf('/') + 1);
var correctPath = imagePath.substr(0, imagePath.lastIndexOf('/') + 1);
this.copyFileToLocalDir(correctPath, currentName, this.createFileName());
}
},(error)=>{
this.loading.dismiss();
this.presentToast('Error while Selecting Image..!');
});
}
Anyhelp Thanks..:)
1 Like
So line #1 works.
What code using a Cordova plugin would be executed then? (I don’t really know as your code doesn’t explain itself) That plugin seems to be missing.
Madhi
June 20, 2017, 2:35pm
3
yeah line 1 works all fine …but when i select a picture and tap on okay to upload it shows this error…
camera ,File Plugin
for this work
Post your ionic cordova plugin list
output please.
Please find out exactly which line is throwing that error and make sure the Ionic Native plugin and Cordova plugin behind it are installed.
Hi Madhi!
Have you found the solution?
I’m stuck w/ similar problem!
Ty
Madhi
June 27, 2017, 3:46pm
9
which part you facing this problem…whether uploading from library or taking pictures from camera?
1 Like
Hi!
I got the problem in iOS env.
Either picking from library or taking pictures from the camera seems to work, at least in UI…
After taking picture or picking from library I get “plugin_not_installed”. I think the problem might be related to “cordova-plugin-file” or maybe “cordova-plugin-filepath” (which is android only).
Anyway I didn’t see “cordova-plugin-filepath” in your plugin list.
Here is mine.
cordova-plugin-camera 2.4.1 "Camera"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-console 1.0.5 "Console"
cordova-plugin-contacts 2.3.1 "Contacts"
cordova-plugin-crop 0.3.1 "CropPlugin"
cordova-plugin-customurlscheme 4.3.0 "Custom URL scheme"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-file-transfer 1.6.3 "File Transfer"
cordova-plugin-filepath 1.0.2 "FilePath"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-google-analytics 1.8.2 "Google Universal Analytics Plugin"
cordova-plugin-network-information 1.3.3 "Network Information"
cordova-plugin-safariviewcontroller 1.4.7 "SafariViewController"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.1 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
cordova-sqlite-storage 2.0.4 "Cordova sqlite storage plugin"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-push 1.10.4 “PushPlugin”
Madhi
June 27, 2017, 5:11pm
11
show your code…there is a problem in code
1 Like
Well, basically it is the same code as yours’
What was wrong in your code?
Madhi
June 28, 2017, 12:56pm
13
My code had error in Copyfiledirectory function i’ll paste my code here to solve your problem
selecting image from gallery code is below
this.platform.ready().then(success=>{
let options = {
quality: 50,
destinationType: this.camera.DestinationType.DATA_URL,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
};
this.camera.getPicture(options).then((data)=>{
let loader= this.loadingctrl.create({
content: "Please Wait..Image is loading",
});
loader.present();
this.uploadedImage = "data:image/jpeg;base64," + data;
loader.dismiss();
},(error)=>{
alert("Failed to Load image.. :(")
});
},(error)=>{
alert("Sorry doesnt enter into the plugin");
});
}
to take pictures from camera code is below
this.platform.ready().then(success=>{
var options = {
quality:50,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType:this.camera.MediaType.PICTURE,
};
this.camera.getPicture(options).then((imageData) =>{
let load = this.loadingctrl.create({
content: 'Please wait..While Image is loading',
});
load.present();
this.uploadedImage = 'data:image/jpeg;base64,' + imageData;
load.dismiss();
}, (error)=>{
alert("Error Occured");
});
});
1 Like
Ty Madhi…
So in order to do not rely on Copy Stuff, you do tried to get inline data from DestinationType.DATA_URL, I presume…
I think i still need DestinationType.FILE_URI in my case…
Do you have any clue @Sujan12 ? bout a working snippet, for camera DestinationType.FILE_URI in Ionic3 iOS?
I’m still getting plugin_not_installed…
Ty!
Well, nevermind.
I skipped copy phase somehow. Now everything started to work.
Ty
Madhi:
data:image/jpeg;base64,’
Do you have any idea of how I could do it with videos?