【发布时间】:2018-08-06 21:20:38
【问题描述】:
我有一个使用 REST API 与 SharePoint 一起工作的 Android 应用程序。我有一个将附件上传到列表项的功能:
public boolean AddAtachment(String name, String id, String fileName, String fileContent) throws IOException, JSONException
{
DefaultHttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(URL + "/_api/web/lists/GetByTitle('" + name + "')/items(" + id+ ")/AttachmentFiles/add(FileName='"+ fileName +"')");
httpPost.setHeader("Cookie", "rtFa=" + RtFa + "; FedAuth=" + FedAuth);
httpPost.setHeader( "X-RequestDigest", GetFormDigestValue());
httpPost.setHeader("body", fileContent);
StringEntity entity = new StringEntity(fileContent);
httpPost.setEntity(entity);
HttpResponse response = client.execute(httpPost);
return response.getStatusLine().getStatusCode() == 200;
}
如果我想上传这样的测试附件
AddAttachment("<name>", "<id>", "fileName.txt", "File content");
它没有任何问题。 现在我在 ImageView 的 Bitmap 中有一个图像
Bitmap map = ((BitmapDrawable)((ImageView)findViewById(R.id.image)).getDrawable()).getBitmap();
是否可以使用 REST 将此位图作为图像附件上传?
【问题讨论】:
标签: java android rest sharepoint bitmap