I've managed to take a picture using Ionic camera API:
async pickImage(sourceType: CameraSource) {
const image = await Camera.getPhoto({
quality: 90,
allowEditing: true,
resultType: CameraResultType.Uri,
source: sourceType,
});
console.log(image);
}
which gives me this:
I've also found that to upload using angular fire storage, but I can't figure out how to connect the two. I don't really understand what are the format in between, what format I should ask to the Camera API and what format should I provide to the AngularFireStorage API.
I tried this:
const filePath = 'name-your-file-path-here';
const ref = this.storage.ref(filePath);
const task = ref.put(image.webPath);
task
.snapshotChanges()
.pipe(finalize(() => console.log(ref.getDownloadURL())))
.subscribe();
But I get this error:
ERROR Error: Uncaught (in promise): FirebaseStorageError: {"code_":"storage/invalid-argument","message_":"Firebase Storage: Invalid argument in `put` at index 0: Expected Blob or File.","serverResponse_":null,"name_":"FirebaseError"}
Your lights would be highly appreciated :)
