|
|
@@ -412,12 +412,10 @@ Alamofire.upload(
|
|
|
```swift
|
|
|
Alamofire.download(.GET, "http://httpbin.org/stream/100") { temporaryURL, response in
|
|
|
let fileManager = NSFileManager.defaultManager()
|
|
|
- if let directoryURL = fileManager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0] as? NSURL {
|
|
|
- let pathComponent = response.suggestedFilename
|
|
|
- return directoryURL.URLByAppendingPathComponent(pathComponent!)
|
|
|
- }
|
|
|
+ let directoryURL = fileManager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0]
|
|
|
+ let pathComponent = response.suggestedFilename
|
|
|
|
|
|
- return temporaryURL
|
|
|
+ return directoryURL.URLByAppendingPathComponent(pathComponent!)
|
|
|
}
|
|
|
```
|
|
|
|
|
|
@@ -437,12 +435,16 @@ Alamofire.download(.GET, "http://httpbin.org/stream/100", destination: destinati
|
|
|
|
|
|
// This closure is NOT called on the main queue for performance
|
|
|
// reasons. To update your ui, dispatch to the main queue.
|
|
|
- dispatch_async(dispatch_get_main_queue) {
|
|
|
+ dispatch_async(dispatch_get_main_queue()) {
|
|
|
print("Total bytes read on main queue: \(totalBytesRead)")
|
|
|
}
|
|
|
}
|
|
|
- .responseData { response in
|
|
|
- print(response)
|
|
|
+ .response { _, _, _, error in
|
|
|
+ if let error = error {
|
|
|
+ print("Failed with error: \(error)")
|
|
|
+ } else {
|
|
|
+ print("Downloaded file successfully")
|
|
|
+ }
|
|
|
}
|
|
|
```
|
|
|
|
|
|
@@ -450,9 +452,9 @@ Alamofire.download(.GET, "http://httpbin.org/stream/100", destination: destinati
|
|
|
|
|
|
```swift
|
|
|
Alamofire.download(.GET, "http://httpbin.org/stream/100", destination: destination)
|
|
|
- .responseData { response in
|
|
|
+ .response { _, _, data, _ in
|
|
|
if let
|
|
|
- data = response.data,
|
|
|
+ data = data,
|
|
|
resumeDataString = NSString(data: data, encoding: NSUTF8StringEncoding)
|
|
|
{
|
|
|
print("Resume Data: \(resumeDataString)")
|
|
|
@@ -466,7 +468,7 @@ Alamofire.download(.GET, "http://httpbin.org/stream/100", destination: destinati
|
|
|
|
|
|
```swift
|
|
|
let download = Alamofire.download(.GET, "http://httpbin.org/stream/100", destination: destination)
|
|
|
-download.responseData { _ in
|
|
|
+download.response { _, _, _, _ in
|
|
|
if let
|
|
|
resumeData = download.resumeData,
|
|
|
resumeDataString = NSString(data: resumeData, encoding: NSUTF8StringEncoding)
|