从本机Android应用程序上传docx,doc和pdf文件到sharepoint

时间:2013-04-02 11:01:08

标签: android sharepoint file-upload sd-card

我正在开发一个Android应用程序来远程访问sharepoint online.I能够使用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());
}

感谢任何帮助.Thankyou

1 个答案:

答案 0 :(得分:0)

您无法在SharePoint Online上打开(但查看)Office Web Apps中的文档,也可以在本地安装它。

在上传之前将办公室文档转换为office 2007/2010标准,即docx,xl​​sx,pptx ......