alexiscn / SynologyKit

Synology File Station SDK for Swift
MIT License
36 stars 8 forks source link

HELP WANTED - Why DownloadFile not report the error? #7

Closed CPiersigilli closed 4 years ago

CPiersigilli commented 4 years ago

If I pass an error or it does not exist path in client.downloadFile(path: String, I have no error: Why?

alexiscn commented 4 years ago

You can check response.statusCode to determine whether download is success.

client.downloadFile(path: file.path + "aaaa", to: destination).downloadProgress { progress in
    print(progress)
}.response { response in
    guard let code = response.response?.statusCode else {
        return
    }
    if code == 200, response.error == nil, let path = response.destinationURL?.path {
        print("File Downloaded to :\(path)")
    } else {
        print("Handle Error")
    }
}