2

我正在开发一个 android 应用程序来远程访问在线共享点。我可以使用 http put 方法上传文件并查看它们,但我无法打开它们。我觉得我没有指定正确的内容类型。这是我的代码:

try {       
    File sdcard = Environment.getExternalStorageDirectory();

    //Get the text file
    File file = new File(sdcard, "gps.doc");

    FileInputStream fIn = new FileInputStream(file);
    BufferedReader myReader = new BufferedReader(
            new InputStreamReader(fIn));
    String aDataRow = "";
    String aBuffer = "";
    while ((aDataRow = myReader.readLine()) != null) {
        aBuffer += aDataRow + "\n";
    }

    System.out.println(aBuffer + "content of the file");

    HttpPut httpupld = new HttpPut("http://mysite.sharepoint.com/Sites/Documents/gps.doc");


    StringEntity entity1 = new StringEntity(aBuffer, "HTTP.UTF_8");
    httpDel.setEntity(entity1);


    System.out.println(title);
    HttpResponse rsp = http2.execute(httpupld);
    respcode=rsp.getStatusLine().getStatusCode();
    System.out.println(respcode);

} catch (Exception e) {
    Log.e("Error: ", e.getMessage());
}

任何帮助表示赞赏。谢谢

4

1 回答 1

0

您无法在 SharePoint Online 或本地安装的 Office Web Apps 中打开(但查看)文档。

在上传之前将您的 office 文档转换为 office 2007/2010 标准,即 docx、xlsx、pptx ...

于 2013-04-02T17:54:44.217 回答