我使用httpclient将img发布到网站。 但我把它塞进了httpclient.execute(httppost)。
在我的本地环境中,我完美地运行它。但是当我将项目发布到SinaAppEngine(Java Local IO
)时受限制) - > sae,执行方法不起作用,因为这样的代码:
reqEntity.addPart(“image”,byteArrayBody);
(Stringbody正常运行)
我的示例代码:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://r.catchoom.com/v1/search");
ByteArrayBody byteArrayBody = new ByteArrayBody(imgByte, "test.jpg");
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
reqEntity.addPart("image", byteArrayBody);
httppost.setEntity(reqEntity);
HttpResponse response = httpclient.execute(httppost);