swift 文件下载,将文件存储到“文件”APP

2022-12-27  本文已影响0人  执念12o3

-通过url下载文件(PDF、Word、Excel、图片)保存到“文件”APP中

下载.gif
 let link = "https://oss-workplace-prod.innoecos.cn/picture/0591960c05c00000_aaaa.docx"
  _ = sessionManager.download(link)?.progress{ (task) in
       SVProgressHUD.showProgress(Float(task.progress.fractionCompleted), status: "下载中…")
  }.completion { [weak self] task in
      SVProgressHUD.dismiss()
      if task.status == .succeeded {// 下载成功
          let activityViewController = UIActivityViewController(activityItems: [URL.init(fileURLWithPath: task.filePath)], applicationActivities: nil)
          self?.present(activityViewController, animated: true, completion: nil)
      }else {
                
      }
  }

Demo地址:https://github.com/jixiang0903/JXDownloadFile

-如果本文帮到了您,欢迎点赞、收藏哟!!!

上一篇 下一篇

猜你喜欢

热点阅读