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

问题描述 投票:0回答:1

当我试图从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);
        }
    });
android mobile appcelerator titanium-mobile
1个回答
0
投票

也许是因为存储权限。

试试这个:

if (Ti.Filesystem.hasStoragePermissions())
{
    // app has storage permission
}
else
{
    Ti.Filesystem.requestStoragePermissions(function(e) 
    {
        if (e.success) 
        {
            // permissions succesfully requested
        }
    });
}
© www.soinside.com 2019 - 2024. All rights reserved.