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
可以請你共享代碼上傳的文件?請在這裏發佈解決方案http://stackoverflow.com/q/21772583/1276636 – Sufian
我用你的代碼在我的項目,但我不知道這個參數:httpDel,respcode,http2 –