如何处理Alamofire中的多部分/相关数据?

问题描述 投票:0回答:1

我的后端服务器多部分/相关的图像数据。如何使用Alamofire在我的iOS客户端处理它?

ios alamofire multipart
1个回答
0
投票

要从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
            }
        }

希望有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.