Created
September 17, 2018 10:25
-
-
Save kimipeng/c8550d8ff8c27041a83f7edf2defc546 to your computer and use it in GitHub Desktop.
Alamofire Upload request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Alamofire 4 - Simple with URL request | |
| Alamofire.upload(fileURL, with: urlRequest).validate().responseData { response in | |
| debugPrint(response) | |
| } | |
| /**************************************************************************************************************/ | |
| // Alamofire 4 - - Complex with URL string | |
| Alamofire.upload(fileURL, to: urlString, method: .put) | |
| .uploadProgress(queue: DispatchQueue.global(qos: .utility)) { progress in | |
| print("Upload Progress: \(progress.fractionCompleted)") | |
| } | |
| .downloadProgress { progress in // called on main queue by default | |
| print("Download Progress: \(progress.fractionCompleted)") | |
| } | |
| .validate { request, response, data in | |
| // Custom evaluation closure now includes data (allows you to parse data to dig out error messages if necessary) | |
| return .success | |
| } | |
| .responseJSON { response in | |
| debugPrint(response) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment