I download image from firebase but i cant make original sized image what should I do? thanks
Asked
Active
Viewed 376 times
-4
-
Can you post some code you've tried so far? – denis_lor Mar 16 '19 at 09:16
-
Please be clear and provide clear description on what you are facing. – Sharkes Monken Mar 16 '19 at 09:54
1 Answers
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