在android 6 appcelerator上通过http请求上传pdf文件时出错

时间:2017-10-10 07:36:05

标签: android mobile appcelerator titanium-mobile

当我尝试从Android上传一个新文件时,它工作正常,但是当我试图从上传后通过OS 6 marshmallow工作的Android设备上传时,它会出现onerror方法,这就是响应:

[ERROR] linker: readlink('/proc/self/fd/54') failed: Permission denied [fd=54]
[ERROR] linker: warning: unable to get realpath for the library "libRSDriver.so". Will use given name.
[ERROR] linker: readlink('/proc/self/fd/54') failed: Permission denied [fd=54]
[ERROR] linker: warning: unable to get realpath for the library "libRSCpuRef.so". Will use given name.
[ERROR] linker: readlink('/proc/self/fd/54') failed: Permission denied [fd=54]
[ERROR] linker: warning: unable to get realpath for the library "libblas.so". Will use given name.

这是代码:

  var intent = Ti.Android.createIntent({
        action: Ti.Android.ACTION_GET_CONTENT,
        type: "application/pdf"
    });

    var x = Ti.Android.createIntentChooser(intent, "Select");
   $.index.getActivity().startActivityForResult(x, function(e) {
        try {
            var doc = Ti.Filesystem.getFile(e.intent.data);

  var xhr = Ti.Network.createHTTPClient({
        onload: function() {
            var result = JSON.parse(this.responseText);
            console.log("File uploaded successfully : ", result);
        },
        onsendstream: __.sendstream,
        onerror: function() {
            console.error("Error in upload file : ", this.responseText);
        },
        timeout: 100000000000000000000
    });
    xhr.open("POST", URL);
    xhr.send(doc);

        } catch (error) {
            console.error("This is error : " + error);
        }
    });

1 个答案:

答案 0 :(得分:0)

可能是因为存储权限。

试试这个:

if (Ti.Filesystem.hasStoragePermissions())
{
    // app has storage permission
}
else
{
    Ti.Filesystem.requestStoragePermissions(function(e) 
    {
        if (e.success) 
        {
            // permissions succesfully requested
        }
    });
}