Results 1 to 4 of 4

Thread: How can I send an image with Spring Framework for Android?

  1. #1
    Join Date
    May 2012
    Posts
    9

    Default How can I send an image with Spring Framework for Android?

    I'm developing an Android 3.1 tablet application.

    This app is using SpringFramework to send JSON message to a server. Here is a working example which send a custom object to server:

    Code:
    	public static Boolean sendSignedEReport(String url, EReport eReport)
    	{
    		try
    		{
    			HttpHeaders requestHeaders = new HttpHeaders();
    			requestHeaders.setAccept(Collections.singletonList(new MediaType("application","json")));
    			HttpEntity<EReport> requestEntity = new HttpEntity<EReport>(eReport, requestHeaders);
    
    			GsonHttpMessageConverter messageConverter = new GsonHttpMessageConverter();
    			List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
    			messageConverters.add(messageConverter);
    
    			HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
    			requestFactory.setReadTimeout(60000);
    
    	        RestTemplate restTemplate = new RestTemplate(requestFactory);
    	        restTemplate.setMessageConverters(messageConverters);
    
    	        ResponseEntity<Boolean> responseEntity = 
                            restTemplate.exchange(url, HttpMethod.POST, requestEntity, Boolean.class);
    
    	        return responseEntity.getBody();
    		}
    		catch (Exception e)
    		{
    			e.printStackTrace();
    		}
    
    		return null;
    	}
    How can I modify this code to send an image?

  2. #2
    Join Date
    Nov 2010
    Posts
    174

    Default

    The showcase app in the samples repository demonstrates how to send an image as multipart/formdata. Here is a link directly to the activity.

    https://github.com/SpringSource/spri...aActivity.java
    Roy Clarkson
    Spring Mobile Projects Lead

  3. #3

    Default

    how do use but i dont no this answer plz tell me

  4. #4
    Join Date
    May 2012
    Posts
    9

    Default

    Quote Originally Posted by Roy Clarkson View Post
    The showcase app in the samples repository demonstrates how to send an image as multipart/formdata. Here is a link directly to the activity.

    https://github.com/SpringSource/spri...aActivity.java
    Thanks for your answer, but it doesn't work for me because WCF doesn't support multi-part messages.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •