【问题标题】:How to Upload iPhone Videos to server using Alamofire in iOS Swift?如何在 iOS Swift 中使用 Alamofire 将 iPhone 视频上传到服务器?
【发布时间】:2017-02-13 22:49:54
【问题描述】:

当我在 iPhone 上录制视频时,我想在 iOS SwiftAlamofire使用视频按钮 上传视频并将其他参数发布到服务器/强>。我该怎么做?

【问题讨论】:

标签: ios iphone swift http alamofire


【解决方案1】:

试试这个

        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)
            }
        }
    })

【讨论】:

    猜你喜欢
    • 2019-11-09
    • 2013-12-04
    • 2016-06-09
    • 1970-01-01
    • 1970-01-01
    • 2015-09-01
    • 2018-01-19
    • 2016-06-07
    • 1970-01-01
    相关资源
    最近更新 更多