Results 1 to 3 of 3

Thread: How to send MULTIPART_FORM_DATA in UTF-8 format

  1. #1
    Join Date
    Feb 2013
    Posts
    2

    Default How to send MULTIPART_FORM_DATA in UTF-8 format

    I'm using spring for android. I want to create registration form in my android app. The user maybe fill out the form with utf-8 format but when data send to server and store in MySQL database I find ?????? in my database field.table's column type set to utf8_general_ci. My question is:
    Do I need to set something for content type in php page OR I need set UTF-8 in my android code?
    Here is my code I'm using: I did same as
    here

    File cacheDirectory = context.getFilesDir();
    tmpFile = new File(cacheDirectory.getPath() + "/" + "avatar.png");
    Resource file = new FileSystemResource(tmpFile);

    MultiValueMap<String, Object> formData = new LinkedMultiValueMap<String, Object>();
    formData.add("firstName", " registerFields[0]");
    formData.add("lastName", registerFields[1]);
    formData.add("userName", registerFields[2]);
    formData.add("file", file);

    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.setContentType(MediaType.MULTIPART_ FORM_DATA);
    HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<MultiValueMap<String, Object>>(
    formData, requestHeaders);

    // Create a new RestTemplate instance
    RestTemplate restTemplate = new RestTemplate(true);

    restTemplate.getMessageConverters().add(
    new GsonHttpMessageConverter());
    restTemplate.getMessageConverters().add(
    new StringHttpMessageConverter());
    ResponseEntity<Success[]> response = restTemplate.exchange(url, HttpMethod.POST, requestEntity,
    Success[].class);

    return response.getBody();
    Last edited by misaghdroid; Feb 16th, 2013 at 05:19 AM.

  2. #2
    Join Date
    Nov 2010
    Posts
    174

    Default

    I see from this question on StackOverflow that you solved this problem by configuring your mysql query on the server.
    Roy Clarkson
    Spring Mobile Projects Lead

  3. #3
    Join Date
    Feb 2013
    Posts
    2

    Default

    Yes,exactly my problem solved that way.

Tags for this Thread

Posting Permissions

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