본문 바로가기
모바일/IOS

Alamofire MultipartForm

by 죠부니 2018. 4. 30.
반응형

1 . 홈페이지

https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#uploading-multipart-form-data


2. 추가 정보

https://medium.com/@hanifsgy/alamofire-multipart-with-parameters-upload-image-from-uiimagepickercontroller-swift-a4abada24ae


3. 적용정보


let parameters: Parameters = []

        Alamofire.upload(

            multipartFormData: { multipartFormData in

            for (key,value) in parameters {

                multipartFormData.append((value as! String).data(using: .utf8)!, withName: key)

            }

        },

            to: "yourDoamin",

            encodingCompletion: { encodingResult in

                switch encodingResult {

                case .success(let upload, _, _):

                    upload.responseJSON { response in

                        debugPrint(response)

                    }

                case .failure(let encodingError):

                    print(encodingError)

                }

        }

        )


반응형