I'm using NSURLSession to download file. Some websites (like Amazon) don't use filenames in URL (like: http://server/file.php?id=22). How can I get that filenames?
Example URL without name: https://odesk-prod-att.s3.amazonaws.com/...oCtjM%3D
I'm using such function:
func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingToURL location: NSURL) {
print("Download finished: \(location.absoluteString)")
}
// Download finished: file:///.../CFNetworkDownload_UTywas.tmp
Check for the suggested filename before creating your own:
downloadTask.response?.suggestedFilename
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With