简体   繁体   中英

How to add an accepted Image MIME Type to Alamofire 5.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 eg 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM