0
下記のコードは、Swift 3で画像ファイルをマルチパートとしてアップロードするのに完全に機能します。しかし、私はSwift 2.2で働くのに似た何かを得ることができませんでした。 Swift 2.2でこれを使用しようとすると、メッセージが表示されますAmbiguous reference to member 'upload(_:_:headers:file:)'
'upload(_:_:headers:file :)'へのあいまいな参照
Swift 2.2でも同じことを達成する方法はありますか?私はいくつかの関連の質問を発見したが、唯一の迅速な3では
func submitFile(entryId: Int, entryDetailValue: String, fieldId: Int, fieldType: String) {
let parameters = [
"entryId": "\(entryId)",
"entryDetail": entryDetailValue,
"fieldId": "\(fieldId)",
"type": fieldType
]
print(parameters)
Alamofire.upload(multipartFormData: { (multipartFormData) in
multipartFormData.append(UIImageJPEGRepresentation(self.imageView.image!, 1)!, withName: "file", fileName: "swift_file.jpeg", mimeType: "image/jpeg")
for (key, value) in parameters {
multipartFormData.append(value.data(using: String.Encoding.utf8)!, withName: key)
}
}, to:"<my endpoint url>")
{ (result) in
switch result {
case .success(let upload, _, _):
upload.uploadProgress(closure: { (progress) in
//Print progress
print(progress)
})
upload.responseData { response in
print(response.result)
}
case .failure(let error):
print(error)
}
}
}
を試してみてくださいスウィフト3で動作するソリューションを発見しました... – hg8