Upload multiple images using AFNetworking

前端 未结 5 976
别跟我提以往
别跟我提以往 2020-12-19 12:30

I used the PickerController and loaded a few images on to a NSMutableArray.

Now i need to upload all of these images at once. am using

5条回答
  •  暖寄归人
    2020-12-19 13:28


    Alamofire is nice source/library for the same:

    Swift 4:

    Alamofire.upload(
        multipartFormData: { multipartFormData in
            multipartFormData.append(unicornImageURL, withName: "unicorn")
            multipartFormData.append(rainbowImageURL, withName: "rainbow")
        },
        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)
            }
        }
    )
    

提交回复
热议问题