應用程序包,當我從文件目錄中的文件複製到應用程序包目錄提示錯誤是這樣的:無法被複制,因爲您沒有權限訪問IOS
「圖像」不能被複制,因爲您沒有權限訪問「資源」。
我的代碼
let fileManager = FileManager.default
let documentDirectoryPath = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first?.appendingPathComponent("Images")
let bundleDirectoryPath = (Bundle.main.resourceURL?.appendingPathComponent("GCDWebUploader.bundle").appendingPathComponent("Contents").appendingPathComponent("Resources").appendingPathComponent("Images"))
do {
try fileManager.copyItem(at: documentDirectoryPath!, to: bundleDirectoryPath!)
} catch let error as NSError {
print("Couldn't copy file to final location! Error:\(error.description)")
}
爲什麼要將圖像移動到您的包目錄? –
我已經實施了簡單的網絡服務器與使用GCDWebUploader.And它做到了成功。但現在我想顯示上傳的圖像從iphone到web.At那時我得到的問題資源未找到。因此,我得到了複製資源的解決方案但這樣做,我正在獲得許可的問題。 – Bhumi
這是否意味着您想要上傳到外部服務器(使用GCDWebUploader)的文檔目錄中有圖像?如果是這樣的話,爲什麼你不顯示你的上傳代碼,你如何從沙盒訪問圖像? –