我的后端服务器多部分/相关的图像数据。如何使用Alamofire在我的iOS客户端处理它?
要从IOS上传多部分图像,示例代码如下:
if let URL = try? URLRequest(url: url, method: .post, headers: nil) {
Alamofire.upload(multipartFormData: { (multipartFormData) in
multipartFormData.append(UIImageJPEGRepresentation(image, 0.001), withName: "file", fileName: params.imageName, mimeType: "image/jpeg")
}, with: URL) { (result) in
switch result {
case .success(let upload, _, _):
//Enter Success Code
case .failure:
//Enter failure Code
}
}
希望有所帮助。