복붙노트

[SWIFT] Alamofire 4.0 업로드 MultipartFormData 헤더

SWIFT

Alamofire 4.0 업로드 MultipartFormData 헤더

해결법


  1. 1.나는 해결책을 얻었다.

    나는 해결책을 얻었다.

    Alamofire.upload(multipartFormData:{ multipartFormData in
             multipartFormData.append(unicornImageURL, withName: "unicorn")
             multipartFormData.append(rainbowImageURL, withName: "rainbow")},
           usingThreshold:UInt64.init(),
           to:"https://httpbin.org/post",
           method:.post, 
           headers:["Authorization": "auth_token"], 
           encodingCompletion: { encodingResult in
            switch encodingResult {
            case .success(let upload, _, _):
                upload.responseJSON { response in
                    debugPrint(response)
                }
            case .failure(let encodingError):
                print(encodingError)
            }
        })
    

    그것은 당신을 도울 것입니다 바랍니다.

  2. from https://stackoverflow.com/questions/39630997/alamofire-4-0-upload-multipartformdata-header by cc-by-sa and MIT license