1

When I record video on iPhone, I would like to press use video button to upload video and post other parameters to server using Alamofire in iOS Swift. How I can do it?

enter image description here

Rajan Maheshwari
  • 14,465
  • 6
  • 64
  • 98
S.Blink
  • 13
  • 1
  • 3
  • 1
    Possible duplicate of [Send POST parameters with MultipartFormData using Alamofire, in iOS Swift](http://stackoverflow.com/questions/31949118/send-post-parameters-with-multipartformdata-using-alamofire-in-ios-swift) – tonik12 Oct 05 '16 at 13:11
  • 1
    Have you tried it? did you work on some code. – Hamza Ansari Oct 05 '16 at 13:11

1 Answers1

0

try this

        Alamofire.upload(.POST, API_URL, multipartFormData: { (formData:MultipartFormData) in
        formData.appendBodyPart(fileURL: NSURL(fileURLWithPath: filePath), name: name)
        }, encodingCompletion: { encodingResult in
        switch encodingResult {
        case .Success(let upload, _, _):
            upload.progress { bytesRead, totalBytesRead, totalBytesExpectedToRead in
                    print(totalBytesRead)
            }
            upload.responseJSON { response in
                    debugPrint(response)
                   //uploaded
            }
        case .Failure(let encodingError):
            //Something went wrong!
            if DEBUG_MODE {
                print(encodingError)
            }
        }
    })
rv7284
  • 1,092
  • 9
  • 25