Swift: Uploading Image to Firebase Cloud Storage When User Closes App

Memory crash with uploading image to Firebase Storage Swift

You need to resize your image to a lower size. We all know that photos captured by ios devices is quite large and sending it as data to a server is also a big workload. You can resize the image to your liking without losing most of its quality.

Check this out for resizing.
https://stackoverflow.com/a/31314494/11138557

Hope this helps: Thanks :)

Swift app crashes when uploading image to firebase

It looks like you forgot to use the child storage node you just created. As such, try replacing this code:

thumbnailStorageRef.child("thumbnails/" + randomString(length: 20) + ".png")
thumbnailStorageRef.put(imageData, metadata: nil, completion: ...

with this instead:

let imageRef = thumbnailStorageRef.child("thumbnails/" + randomString(length: 20) + ".png")
imageRef.put(imageData, metadata: nil, completion: ...

This change should fix your current issue ;)

Image not uploading to Firebase Storage

Since I forgot I had a @State var avatarImage = UIImage(systemName: "person.fill")! inside a struct of type View, it was taking the picture the user selected and doing nothing, because the code was taking another @State var as the picture with the info, to upload to Firebase (debugger showed self.image was throwing nil).



Related Topics



Leave a reply



Submit