2

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.

Sean Dev
  • 1,239
  • 1
  • 17
  • 31

1 Answers1

3
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.

Sean Dev
  • 1,239
  • 1
  • 17
  • 31
  • Probably not included in the Alamofire 5 migration guide because it's part of the separate AlamofireImage component. I had to add it to my podfile alongside Alamofire: `pod 'AlamofireImage', '~> 4.1'`. – adamjansch Jul 07 '22 at 07:41