2013-04-02 53 views
2

我正在開發一個android應用程序來遠程訪問sharepoint online.I能夠使用http put方法上傳文件並查看它們,但我無法打開它們。我覺得我不指定正確的內容type.Here是我的代碼:從原生android應用程序上傳docx,doc和pdf文件到在線共享點

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()); 
} 

任何幫助是appreciated.Thankyou

+1

可以請你共享代碼上傳的文件?請在這裏發佈解決方案http://stackoverflow.com/q/21772583/1276636 – Sufian

+1

我用你的代碼在我的項目,但我不知道這個參數:httpDel,respcode,http2 –

回答

0

您無法打開(但鑑於)文檔中的Office Web Apps無論是在SharePoint在線或如果您有本地安裝。

上傳之前將您的辦公文檔到辦公室2007/2010標準,這是DOCX,XLSX,PPTX ...

+0

我試過這樣做,但仍面臨相同問題.. – interns

相關問題