简体   繁体   English

如何将可接受的图像 MIME 类型添加到 Alamofire 5.2

[英]How to add an accepted Image MIME Type to Alamofire 5.2

I recently migrated to Alamofire 5.2我最近迁移到了 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我们的后端对于我们希望在前端支持的图像有不正确的 MIME 类型,例如 image.jpg 而不是 image.jpeg

Old version of Alamofire allowed for exceptions using:旧版本的 Alamofire 允许使用以下例外:

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

As can be seen here by Christian Noon on GitHub in the Alamofire Issues.正如 Christian Noon 在 GitHub 在 Alamofire Issues 中看到的那样。

How do I implement this exception in Alamofire 5.2?如何在 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.我已经尝试查看引用 MIME 类型的位置,看看我是否可以更新数组但没有成功。

import AlamofireImage    

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

I found this by searching for image/jpeg which is the correct and valid MIME type.我通过搜索 image/jpeg 找到了它,它是正确有效的 MIME 类型。 This brought me to the ImageResponseSerializer class where I saw the function I was looking for.这将我带到了 ImageResponseSerializer class,在那里我看到了我正在寻找的 function。

Ideally this should probably be included in the Alamofire 5 migration guide.理想情况下,这应该包含在 Alamofire 5 迁移指南中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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