gpt4 book ai didi

ios - 操作无法完成。 ( cocoa 错误 -1。) - PHPhotoLibrary

转载 作者:搜寻专家 更新时间:2023-10-31 21:46:34 33 4
gpt4 key购买 nike

您好,我正在尝试将下载的 mp4 文件保存到我的画廊。

使用 , downloadTask 下载 url>

func urlSession(_ session: URLSession,
downloadTask: URLSessionDownloadTask,
didFinishDownloadingTo location: URL){
}

我正在获取网址

file:///private/var/mobile/Containers/Data/Application/8D761DFE-C050-426D-B91C-61DE441FB496/Library/Caches/com.apple.nsurlsessiond/Downloads/com.te.dn/CFNetworkDownload_KFSYSW.tmp

我正在通过使用创建路径,

let path = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)
let documentDirectoryPath:String = path[0]
let fileManager = FileManager()
let destinationURLForFile = URL(fileURLWithPath: documentDirectoryPath.appendingFormat("/file1.mp4"))

if fileManager.fileExists(atPath: destinationURLForFile.path){

}
else{
do {
try fileManager.moveItem(at: location, to: destinationURLForFile)
// show file

}catch{
print("An error occurred while moving file to destination url")
}
}

我可以成功移动文件(移动时没有出现任何错误)。

然后我尝试保存文件出错

let url = URL(fileURLWithPath: destinationURLForFile.path)

网址值为:

file:///var/mobile/Containers/Data/Application/8DF0C849-56A1-42B3-A081-0C992D18F973/Documents/file1.mp4


PHPhotoLibrary.shared().performChanges({
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: url)
}) { saved, error in
if saved {
let alertController = UIAlertController(title: "Your video was successfully saved", message: nil, preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .default, handler: nil)
alertController.addAction(defaultAction)
self.present(alertController, animated: true, completion: nil)
}
else
{
print(error?.localizedDescription ?? "f")
}

}

o/p:错误:- 操作无法完成。 ( cocoa 错误 -1。)

最佳答案

无法从 m3u8 文件保存视频。

但是,我们可以离线下载视频,也不能将视频移动到图库。

这里是苹果代码HLSCatalog

关于ios - 操作无法完成。 ( cocoa 错误 -1。) - PHPhotoLibrary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47068666/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com