代码之家  ›  专栏  ›  技术社区  ›  Rahul Patel

在swift中从weburl识别资源名称和扩展名

  •  -1
  • Rahul Patel  · 技术社区  · 7 年前

    enter image description here 在chrome中粘贴到url下面,chrome将为您提供带有扩展名的确切文件名。

    https://www.videvo.net/download_new.php?hash=f654a8d8307038ae523769b502f35ab5&test_new_server=1

    提前谢谢你。

    0 回复  |  直到 7 年前
        1
  •  2
  •   Piyush    7 年前

    你可以用 downloadTask.response?.suggestedFilename 从下面 func

     func URLSession(session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingToURL location: NSURL) {
            print(downloadTask.response?.suggestedFilename as Any)
            print(downloadTask.response?.mimeType as Any)
    
        }