2016-09-14 50 views
0

我試圖做一個上傳使用Alamofire此代碼(其中photo.image是一個UIImage)表達型「()」是模糊的沒有更多的情況下

let imageData = UIImageJPEGRepresentation(photo.image, 1.0) 

Alamofire.upload(
    multipartFormData: { multipartFormData in 
     multipartFormData.append(data: imageData!, withName: "unicorn") 
    }, 
    to: "https://httpbin.org/post", 
    encodingCompletion: { encodingResult in 
     switch encodingResult { 
     case .success(let upload, _, _): 
      upload.responseJSON { response in 
       debugPrint(response) 
      } 
     case .failure(let encodingError): 
      print(encodingError) 
     } 
    } 
) 

然而,這告訴我「表達類型「()」不明確沒有更多的上下文

我不知道我在做什麼錯在這裏,他會喜歡一些建議

+0

在哪一行中有這個問題? –

+0

這是什麼Alamofire版本?我無法找到任何上傳方法重載的「to」參數 – marosoaie

+0

@MarcoSantarossa:第一個 –

回答

1

我錯了論據multipartFormData這裏是什麼工作:。

multipartFormData: { multipartFormData in 
        multipartFormData.append(imageData!, withName: "photo", fileName: "image.jpg", mimeType: "image/jpg") 
       }, 
+0

感謝您發表此內容。從我的超過150億搜索解決方案到愚蠢的Swift神祕錯誤,最簡單的解決方法得益於你的帖子。乾杯! –

相關問題