Alamofire Multipart在XCode 9.4.1中不起作用

时间:2018-07-01 07:50:06

标签: ios swift alamofire

当我将XCode版本升级到9.4.1时,Alamofire Multipart无法正常工作,我也不知道为什么。它可以在以前的XCode版本中完全正常工作。

请让我知道如何解决它。谢谢

Alamofire.upload(
    multipartFormData: { multipartFormData in
        multipartFormData.append(self.imageFrontData, withName: "front-photo", fileName: "front-photo.png", mimeType: "image/png")
        multipartFormData.append(self.imageBackData, withName: "back-photo", fileName: "back-photo.png", mimeType: "image/png")
        for (key, value) in parameters {
            multipartFormData.append((value?.data(using: String.Encoding.utf8)!)!, withName: key)
        }
}, usingThreshold: UInt64.init(), to: uploadURL!, method: .post, headers: headers) { (result) in
    switch result {
        case .success(let upload, _, _):
            upload.responseJSON { response in
                print("Succesfully uploaded")
                if let err = response.error{
                    print("err \(err.localizedDescription)")
                }
            }
        case .failure(let encodingError):

        }
}

0 个答案:

没有答案