Phonegap,Cocoa错误257 - 操作无法完成。不允许操作

时间:2013-04-04 13:45:29

标签: ios xcode cordova file-upload

我遇到了一个我找不到任何解决方案的问题。 我正在使用Xcode版本4.5.1(4G1004),Cordova-2.5.0,iPhone4S(Ver.5.0(9A334))

我要做的是使用

将文件从本地文件系统(/var/mobile/Library/Notes/notes.sqlite)发送到远程服务器
var ft = new FileTransfer();
ft.upload("/var/mobile/Library/Notes/notes.sqlite", encodeURI("http://myserver.com/fileUpload.php"), win, fail, null);

function win(r) {
            console.log("Code = " + r.responseCode);
            console.log("Response = " + r.response);
            console.log("Sent = " + r.bytesSent);
        }

        function fail(error) {
            alert("An error has occurred: Code = " + error.code);
            console.log("upload error source " + error.source);
            console.log("upload error target " + error.target);
        }

但它失败并出现错误:

Error opening file /var/mobile/Library/Notes/notes.sqlite: Error Domain=NSCocoaErrorDomain Code=257 "The operation couldn’t be completed. (Cocoa error 257.)" UserInfo=0x164070 {NSFilePath=/var/mobile/Library/Notes/notes.sqlite, NSUnderlyingError=0x148670 "The operation couldn’t be completed. Operation not permitted"}
FileTransferError {
    code = 1;
    source = "/var/mobile/Library/Notes/notes.sqlite";
    target = "xxxxxxxxxxxxxxxxxxx/fileUpload.php";
}

如果我对联系人图片做同样的事情,一切正常。

ft.upload("/var/mobile/Applications/367E3D28-2912-4E2B-B798-B49D71F9CAE6/tmp/photo_HHcOG", encodeURI("xxxxxxxxxxx/fileUpload.php"), win, fail, null);

我查看了档案和提交但没有找到任何解决方案,除了它是某种权限问题,我从(Cocoa error 257.)错误中理解。 有没有办法为文件notes.sqlite分配权限(我检查了notes.sqlite的权限(使用文件管理器),并且与photo_HHcOG相同)。我想也许它不是文件权限,而是文件夹或用户权限,因为我试图更改notes.sqlite的权限,为每个人写,但结果相同。

有人知道可能是什么问题,是否已经修复,并指出了正确的方向?

谢谢。

1 个答案:

答案 0 :(得分:0)

来自Apple

不,你不能。 沙箱是有原因的。

这意味着您只能在app文件夹中读取/创建文件。

两个应用可以使用UIDocumentInteractionController

进行通信

但现在没有使用股票笔记app。