gpt4 book ai didi

swift - 如何将 AVCaptureMovieFileOutput 保存到 iCloud

转载 作者:行者123 更新时间:2023-11-30 12:30:14 24 4
gpt4 key购买 nike

我已经创建了一个电影文件,并且能够将其本地保存到设备上。不过,我想利用 icloud 文档并将其保存到 icloud 并公开共享。如何使用 swift 做到这一点?

我找到了这个用于保存一般文件的链接,Save iOS 8 Documents to iCloud Drive 。我猜测该方法是首先将其本地保存到设备上,然后将其保存到云驱动器上。但有人有这方面的工作样本吗?例如,下面的 UIDocument 函数的可能实现是什么?

override func contents(forType typeName: String) throws -> Any {

}

override func load(fromContents contents: Any, ofType typeName: String?) throws {

}

最佳答案

不幸的是,用 iCloud Drive“共享”东西几乎是不可能的。使用 Dropbox。这是保存文件的代码,您需要首先设置 DropboxClientsManager.authorizedClient 变量,当然,请查看他们的开发页面。 Corepath 是您的文件的路径。

let client = DropboxClientsManager.authorizedClient!
client.files.upload(path: corePath, mode: .overwrite, autorename: false, input: textData).response { response, error in

if let metadata = response {
// Get file (or folder) metadata
}
if let error = error {
switch error {
case .routeError(let boxed, let requestId):
switch boxed.unboxed {
case .path(let failedPath):
//rint("Failed update 2 path: \(failedPath)")

NotificationCenter.default.post(name: Notification.Name("dbFileCreationError"), object: nil, userInfo: nil)
break

default:
////rint("Unknown \(error)")
break
}
case .internalServerError(let code, let message, let requestId):
////rint("InternalServerError[\(requestId)]: \(code): \(message)")
NotificationCenter.default.post(name: Notification.Name("dbInternalServerError"), object: nil, userInfo: nil)
break
case .badInputError(let message, let requestId):
////rint("BadInputError[\(requestId)]: \(message)")
NotificationCenter.default.post(name: Notification.Name("dbBadInputError"), object: nil, userInfo: nil)
break
case .authError(let authError, let requestId):
////rint("AuthError[\(requestId)]: \(authError)")
NotificationCenter.default.post(name: Notification.Name("dbAuthError"), object: nil, userInfo: nil)
break
case .rateLimitError(let rateLimitError, let requestId):
////rint("RateLimitError[\(requestId)]: \(rateLimitError)")
NotificationCenter.default.post(name: Notification.Name("dbRateLimitError"), object: nil, userInfo: nil)
break
case .httpError(let code, let message, let requestId):
////rint("HTTPError[\(requestId)]: \(code): \(message)")
NotificationCenter.default.post(name: Notification.Name("dbHTTPError"), object: nil, userInfo: nil)
break
default:
break
}
}
}
}

关于swift - 如何将 AVCaptureMovieFileOutput 保存到 iCloud,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43646113/

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