【发布时间】:2011-09-04 20:32:27
【问题描述】:
我找到了 1 个关于这个问题的帖子,它确实部分回答了这个问题,但恐怕我需要一些细节。
我目前正在尝试将 BlobStore 与我的 android 应用程序一起使用,除了 501 错误(HTTP 服务器无法处理您的请求)之外,我什么也得不到。
他是我的密码;
HttpPost httpPostImg = new HttpPost(url);
Header header = new BasicHeader("Content-Type", "multipart/form-data");
Header h = new BasicHeader("Connection", "keep-alive");
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
FormBodyPart form = new FormBodyPart("myFile",new ByteArrayBody(image,"multipart/form- data","pict.jpeg"));
entity.addPart(form);
httpPostImg.setEntity(entity);
httpPostImg.setHeader(header);
httpPostImg.setHeader(h);
response = httpClient.execute(httpPostImg);
processResponse(response);
我通过一个运行良好的 GET 请求获取 URL。我还尝试了一个包含 ByteArrayBody 的 FormBodyPart,并将 ByteArrayBody 的 mime 类型设置为“multipart/form-data”,但没有任何效果。我总是收到 501 错误(服务器无法处理您的请求)。
谢谢,感谢所有答案。
【问题讨论】:
-
您是否尝试过将您的 Android 应用上传的数据与常规浏览器表单帖子进行比较,看看差异在哪里?
-
我使用了wireshark。数据看起来几乎一样,除了边界问题。 “多部分解剖器找不到边界参数”我错过了什么? ://
-
好吧,这真的很棘手。似乎根本不需要标题,而且它们把一切都搞砸了。
标签: java android google-app-engine http blobstore