我创建了一个创建 CSV 文件的小应用程序,现在我想将其上传到保管箱文件夹。
import SwiftyDropbox
class ViewController: UIViewController {
func myButtonInControllerPressed() {
DropboxClientsManager.authorizeFromController(UIApplication.shared,
controller: self,
openURL: { (url: URL) -> Void in
UIApplication.shared.openURL(url)
})
}
let client = DropboxClientsManager.authorizedClient
let fileData = "teste.csv".data(using: String.Encoding.utf8, allowLossyConversion: false)!
client?.files.upload(path: "/test/path/in/Dropbox/account/HealthkitFromTheGround", input: fileData)
.response { response, error in
if let response = response {
print(response)
} else if let error = error {
print(error)
}
}
.progress { progressData in
print(progressData)
}
let fileName = "teste.csv"
let tempDir = NSTemporaryDirectory()
let fileURL = URL(fileURLWithPath: tempDir, isDirectory: true).appendingPathComponent(fileName)
do {
try csvString.write(to: fileURL, atomically: true, encoding: .utf8)
print("Created file")
} catch {
print("Failed to create file: \(error)")
return
}
我应该怎么做才能直接写入应用程序保管箱文件夹?
谢谢!