-4

I download image from firebase but i cant make original sized image what should I do? thanks

matmano
  • 1
  • 2

1 Answers1

0

As from Firebase documentation says:

Download in memory

Download the file to an NSData object in memory using the dataWithMaxSize:completion: method. This is the easiest way to quickly download a file, but it must load entire contents of your file into memory. If you request a file larger than your app's available memory, your app will crash. To protect against memory issues, make sure to set the max size to something you know your app can handle, or use another download method.

Once you have a reference to the path of an image you can request to download the image in a particular file size. Source -> https://firebase.google.com/docs/storage/ios/download-files

// Create a reference to the file you want to download
let islandRef = storageRef.child("images/island.jpg")

// Download in memory with a maximum allowed size of 1MB (1 * 1024 * 1024 bytes)
islandRef.getData(maxSize: 1 * 1024 * 1024) { data, error in
  if let error = error {
    // Uh-oh, an error occurred!
  } else {
    // Data for "images/island.jpg" is returned
    let image = UIImage(data: data!)
     }
  }
Community
  • 1
  • 1
Sharkes Monken
  • 661
  • 5
  • 23