i don't know why but i have followed so many instruction on the web but seems i cannot work it when i try to use the second parameter for the function .putString it always return this error :
[object Object]
at viewWrappedDebugError (core.js:9503)
at callWithDebugContext (core.js:14749)
at Object.debugHandleEvent [as handleEvent] (core.js:14326)
at dispatchEvent (core.js:9703)
at core.js:10317
at HTMLButtonElement.<anonymous> (platform-browser.js:2614)
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (core.js:4617)
at t.invokeTask (polyfills.js:3)
at r.runTask (polyfills.js:3)
the is not help for me so can anybody help me on this heres my code:
captureDataUrl: string;
capture() {
//setup camera options
const cameraOptions: CameraOptions = {
quality: 50,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
};
this.camera.getPicture(cameraOptions).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64:
this.captureDataUrl = 'data:image/jpeg;base64,' + imageData;
alert(this.captureDataUrl);
}, (err) => {
alert(err);
});
}
upload() : AngularFireUploadTask {
const filename = 'filename';
this.afStorage.ref(`users/${filename}.jpg`)
.putString(this.captureDataUrl,'data_url')
.then((snapshot)=>{
alert(snapshot);
})
.catch((err)=>{
alert(err);
})
}