ios - 快速识别来自 weburl 的资源名称和扩展名
问题描述
在 chrome 中粘贴下面的 url,chrome 将为您提供带有扩展名的确切文件名。
https://www.videvo.net/download_new.php?hash=f654a8d8307038ae523769b502f35ab5&test_new_server=1
就像 chrome 知道名称和扩展名一样,我想用 swift 做到这一点。
提前谢谢你。
解决方案
您可以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)
}
推荐阅读
- sql - 包含 NESTED+REPEATED 字段的 BigQuery MERGE 语句
- imagemagick - 使用 magick 命令添加上下边框
- reactjs - 使用 UseEffect 和 UseState 对功能组件中的承诺做出反应
- laravel - Vue组件模板在刀片中与@if一起使用时不呈现,php
- sql-server - 无法使用架构上的更改权限更改架构中的表
- mysql - MYSQL:使用加载csv文件时应该使用什么文件目录?
- json - 如何在机器人框架中发送带有 json 有效负载的 GET 请求?
- python - python/Selenium --> find_elements_by_xpath 方法找不到所有元素
- java - Redisson RRingBuffer容量不能在同一个key下动态改变
- jquery - 在 Iphone(Apple 产品)浏览器上滚动