How to add an accepted Image MIME Type to Alamofire 5.2

1k views Asked by At

I recently migrated to Alamofire 5.2

Our backend has incorrect MIME types for images that we're expected to support on the front end e.g. image.jpg instead of image.jpeg

Old version of Alamofire allowed for exceptions using:

DataRequest.addAcceptableImageContentTypes(["image/jpg"])

As can be seen here by Christian Noon on GitHub in the Alamofire Issues.

How do I implement this exception in Alamofire 5.2? I've tried looking at the where the MIME types are referenced and seeing if I could update the array but no luck.

1

There are 1 answers

1
Sean Dev On BEST ANSWER
import AlamofireImage    

ImageResponseSerializer.addAcceptableImageContentTypes(["image/jpg"])

I found this by searching for image/jpeg which is the correct and valid MIME type. This brought me to the ImageResponseSerializer class where I saw the function I was looking for.

Ideally this should probably be included in the Alamofire 5 migration guide.