Upload image in local storage phone using Ionic 3
Nota ni bakal dikemaskini~
- camera
- file
- webview
- domsanitizer
const options: CameraOptions = {
              quality: 70,
              destinationType: this.camera.DestinationType.FILE_URI,
              encodingType: this.camera.EncodingType.JPEG,
              sourceType : this.camera.PictureSourceType.CAMERA,
              mediaType: this.camera.MediaType.PICTURE,
              allowEdit : true,
              targetWidth: 500,
              targetHeight: 500,
              saveToPhotoAlbum: true
            }
            const tempImage = this.camera.getPicture(options).then((imageData) => {
              var tempFilename = imageData.substr(imageData.lastIndexOf('/') + 1);
              tempFilename = tempFilename.substr(0, tempFilename.lastIndexOf("?"));
              var tempBaseFilesystemPath = imageData.substr(0, imageData.lastIndexOf('/') + 1);
              var newBaseFilesystemPath = this.file.dataDirectory;
              this.file.copyFile(tempBaseFilesystemPath, tempFilename, newBaseFilesystemPath, tempFilename);
              var storedPhoto = newBaseFilesystemPath + tempFilename;
              var resolvedImg = this.win.Ionic.WebView.convertFileSrc(storedPhoto);
              this.photo = this.sanitizer.bypassSecurityTrustStyle('url(' + resolvedImg + ')');
              this.global.sendNotification('Success');
            }, (err) => {
              this.global.sendNotification('Failed');
            });
Sumber rujukan : 
Storing Photos with the Cordova Camera and File Plugins
Ionic 3 Plugin - File : https://ionicframework.com/docs/v3/native/file/
Ionic 3 Plugin - Ionic Webview : https://ionicframework.com/docs/native/ionic-webview
Not allowed to load local resource: ionic 3 android
WARNING: sanitizing unsafe style value url
 
 
Ulasan