So I was building an app as an assignment from school which is supposed to upload pictures and forms to a server. On the broswer when using "ionic serve" the images upload just fine. But on the phone after installation after selecting the image you wish to upload it loads and loads forever and the image is not uploaded
function that takes in the image
async UploadImage(){
const image= await Camera.getPhoto({
quality: 90,
allowEditing: false,
resultType: CameraResultType.Base64,
source: CameraSource.Photos,
});
console.log(image);
if(image){
const loading= await this.loadingController.create();
await loading.present();
let result= await this.formUpload.uploadImage(image);
loading.dismiss();
console.log(result[1])
if(result[0]==false){
const toaster= await this.toastController.create({
position: 'bottom',
message: "Image not uploaded",
color: 'danger',
duration: 3000,
});
toaster.present();
}else{
this.images.push(result[1])
}
}
}
function that uploads the image and returns the url
async uploadImage(cameraFile: Photo){
let now=new Date()
const user=this.auth.currentUser;
const path= `uploads/${user.uid}/formImage${now}.png`;
const storageref= ref(this.fireStorage, path);
try {
await uploadString(storageref, cameraFile.base64String, 'base64');
let imageUrl: string;
imageUrl =await getDownloadURL (storageref);
console.log(imageUrl)
return [true, imageUrl];
} catch (error) {
return error
}
}
On the browser the image uploads perfectly well but on the phone just loads and loads and loads and nothing is done