使用意图将文件上传到Google云端硬盘

sw先生

我收到错误消息:“上传失败。无法安排1个文件进行上传”。我正在尝试创建一个简单的文件浏览器。当用户点击listView上的非文件夹项时,会出现一个Google云端硬盘上传对话框,但是当我点击Google云端硬盘对话框中的SAVE按钮时出现错误。下面显示了我的编码。请告诉我我做错了哪些部分。谢谢你。

protected void onListItemClick(ListView l, View v, int position, long id) {
    // TODO Auto-generated method stub
    super.onListItemClick(l, v, position, id);

    Option o = adapter.getItem(position);
    if(o.getData().equalsIgnoreCase("folder")||o.getData().equalsIgnoreCase("parent directory")){
        currentDir = new File(o.getPath());
        fill(currentDir);
    }
    else
    {
        onFileClick(o);
    }
}

private void onFileClick(Option o)
{
    Toast.makeText(this, "File Clicked: "+o.getName(), Toast.LENGTH_SHORT).show();
    String uri = o.getPath();
    Uri uploadUri = Uri.parse(uri);
    Toast.makeText(this, "This file is located at: "+uploadUri, Toast.LENGTH_SHORT).show();
    if (uri.contains(".txt")) {
        Intent uploadIntent = ShareCompat.IntentBuilder.from(this)
                .setText("Share Document")
                .setType("application/txt")
                .setStream(uploadUri)
                .getIntent()
                .setPackage("com.google.android.apps.docs");
        startActivity(uploadIntent);
    }else{
        //TODO: what to do when it is other file format
    }
}
比努贾亚拉姆

在onFileClick()中:

改变

String uri = o.getPath(); 

String uri = "file://" + o.getPath(); 

然后你去了!:)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

将文件上传到Google云端硬盘?

使用gapi将文件上传到Google云端硬盘

使用php curl将文件上传到Google云端硬盘

使用Dropzone将文件上传到Google云端硬盘

在后台将文件上传到Google云端硬盘

将文件从网络上传到Google云端硬盘

将文件从Blobstore上传到Google云端硬盘

使用http上传到Google云端硬盘文件夹

使用Windows服务自动将文件上传到Google云端硬盘文件流

Python:如何使用folderId将文件上传到Google云端硬盘中的特定文件夹

使用PyDrive将图片上传到Google云端硬盘

使用Curl将文件上传到Google云端硬盘会显示401

使用Android将文本文件上传到Google云端硬盘

使用cURL将文件上传到Google云端硬盘-access_token过期问题

使用javascript(无html表单)以编程方式将文件上传到Google云端硬盘

如何使用Apps脚本将云端硬盘中的现有文件上传到云端硬盘

Google云端硬盘API将文件上传到Java团队硬盘

如何使用REST API将新修订版本上传到Google云端硬盘中的特定文件?

无法将文件上传到Google云端硬盘中的文件夹

无法将文件上传到Google云端硬盘上的特定文件夹

将文件上传到Google云端硬盘中的特定文件夹

Angular Gapi将简单文本上传到Google云端硬盘

将文件上传到Google云端硬盘后,如何处理该事件(调用脚本)?

将内存中的文件下载并上传到Google云端硬盘

通过Javascript API将多个文件上传到Google云端硬盘的最佳策略

可靠地将大文件上传到Google云端硬盘

通过HTTP请求(C)将文件上传到Google云端硬盘

C:通过HTTP请求将文件上传到Google云端硬盘的错误408响应

如何将持续更新的文件夹上传到Google云端硬盘?