Error decoding Base64 images stored in AWS S3

Hi,

Using the function snippets provided at https://docs.mongodb.com/realm/services/snippets/s3/, I’m successfully able to upload Base64 images from my Swift app to an S3 bucket. I’ve checked that the images in the bucket aren’t corrupted by downloading them directly from my AWS S3 dashboard and seeing that they look fine. However, when using the “Get an Image From S3” snippet function in my app, decoding the Base64 images is resulting in “Fatal error: Unexpectedly found nil while unwrapping an Optional value.” I’m wondering if anyone could point out what I’m doing wrong here:

Thank you,
Jack

This is what I used to encode the images by the way:

Perhaps the better question may be, how do I access a returned image using this provided snippet?

Finally figured it out :slight_smile: I’m still not sure if there’s a way to decode properly in Swift using the snippet above as is, but incorporating BSON.Binary.toBase64() (https://docs.mongodb.com/realm/functions/json-and-bson/#mongodb-method-BSON.Binary.toBase64) into the provided snippet seemed to do the trick.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.