我正在开发一个 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());
}
任何帮助表示赞赏。谢谢