Ryuichi Aida Ryuichi Aida - 1 month ago 13
Swift Question

Fail to download the images from Firebase Storage

I fail to download the images from Firebase Storage.
The following is code.

let ref = storageRef.child("xxxx.jpg")
ref.data(withMaxSize: 1 * 1 * 1) { (data, error) in
if error != nil {
// Uh-oh, an error occurred!
} else {
}
}


Error always return. The following is error message.

"Optional(Error Domain=FIRStorageErrorDomain Code=-13032 \"Attempeted to download object with size of 254078 bytes, which exceeds the maximum size of 1 bytes. Consider raising the maximum download size, or using [FIRStorageReference writeToFile:]\" UserInfo={totalSize=254078, NSLocalizedDescription=Attempeted to download object with size of 254078 bytes, which exceeds the maximum size of 1 bytes. Consider raising the maximum download size, or using [FIRStorageReference writeToFile:], maxAllowedSize=1})"


If anyone knows how to do this please help.

Answer

You need to increase the size that you allow to be downloaded

Try this...

let imageRef = httpsRef.data(withMaxSize: 15 * 1024 * 1024, completion: {(data, error) in
        if error == nil {
            print("got imagedata \(data)")
        } else {
            print("ERROR DOWNLOADING IMAGE : \(error)")
        }

    })