相关疑难解决方法(0)

使用Http Post发送图像

我想使用Http Post将图像从android客户端发送到Django服务器.图像从图库中选择.目前,我使用列表值名称Pairs将必要的数据发送到服务器并从JSON接收来自Django的响应.是否可以将相同的方法用于图像(使用嵌入在JSON响应中的图像的URL)?

此外,这是一种更好的方法:远程访问图像而无需从服务器下载图像或下载并将其存储在Bitmap数组中并在本地使用它们?图像数量很少(<10)且尺寸较小(50*50倾角).

任何解决这些问题的教程都将非常感激.

编辑:从库中选择的图像在将其缩放到所需大小后发送到服务器.

django android http

126
推荐指数
4
解决办法
14万
查看次数

使用Android SDK发布多部分请求

我正在尝试做一些我认为相对简单的事情:使用Android SDK将图像上传到服务器.我找到了很多示例代码:

http://groups.google.com/group/android-developers/browse_thread/thread/f9e17bbaf50c5fc/46145fcacd450e48

http://linklens.blogspot.com/2009/06/android-multipart-upload.html

但是对我来说都不起作用.我一直遇到的困惑是制作多部分请求真正需要的东西.Android的多部分上传(带图片)的最简单方法是什么?

任何帮助或建议将不胜感激!

android http multipartform-data android-sdk-2.1

78
推荐指数
4
解决办法
13万
查看次数

Android Httpclient [NoSuchMethodError:org.apache.http.entity.ContentType.create]

我想从android上传图像到spring控制器.我已经使用rest api call(httpclient)连接了android和spring我的代码是:

final String jsonUserMo = gson.toJson(userMO);
    final StringBuilder contactLists = new StringBuilder();
    HttpClient client = new DefaultHttpClient();
    HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000); // Timeout
    try {
        MultipartEntityBuilder builder = MultipartEntityBuilder.create();
        builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
        FileBody profileFile = new FileBody(profileImage);
        builder.addPart("uploadImg", profileFile);
        HttpEntity entity = builder.build();
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("userMO", jsonUserMo));
        HttpPost post = new HttpPost(Constants.ROOTURL+"/media/uploadUserImage");
        post.setEntity(entity);
        post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        Log.i("Ringee",post.toString());
        HttpResponse response = client.execute(post);
        BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
        contactLists.append(rd.readLine());
    } catch (Exception e) {
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

个人资料图片是文件.并使用mutipartentity上传但我在android中出错了

Caused by: java.lang.NoSuchMethodError: …
Run Code Online (Sandbox Code Playgroud)

java spring android

4
推荐指数
1
解决办法
5704
查看次数