Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

HashMap & Hashtable Truncate Strings from the end

I'm trying to send a Base64 Image String to a server using Volley Put method. Everywhere there's only one type of solution and it doesn't work for me. I also referred to this question, but I don't have such debugger issue either.

I've already tried using ConcurrentHashMap, Hashtables and HashMaps but all of them truncate my string from the end, for the same amount as the header. For example, if my Image String is "XXYYZZAABBCC" and my header is "data", parameters.put("data",ImageString); gives me "{data=XXYYZZ" as the actual parameter. To confirm this is not just a debugger issue, I've also checked both string lengths and they're differing in size. The wrong string goes to the server and my image isn't recoverable there!

I'm extracting the string stored to the database in a previous activity. I know the string is right because as a test case I put another activity, extracted the same string from the database, converted it to a bitmap and populated the ImageView with it. It showed the correct image.

Comparison Screen shot for both strings. The Highlighted part is missing on the string sent to the server and is the same size as the TAG for Map.

ImageString = database.getImage();
StringRequest stringReq = new StringRequest(Request.Method.PUT,url,
  new Response.Listener<String>() {
  @Override
  public void onResponse(String response) {
    Toast.makeText(getContext(),response, Toast.LENGTH_LONG).show();
    //Log.d("DO RESPONSE", response);
  }
},
  new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError error) {
      Toast.makeText(getContext(), error.toString(),Toast.LENGTH_LONG).show();
      error.printStackTrace();
    }
 },
  protected Map<String, String> getParams() {
    Map<String, String> params = new Hashtable<>();
    params.put("data:image/jpeg;base64,",ImageString);
    Log.wtf("PARAMETERS", params.toString());
    Log.wtf("Length Of Data Sending", ""+params.get("data:image/jpeg;base64,").length());
    return params;
    }
);
queue.add(stringReq);

I'm a little new to android programming so any clues/help will be very appreciated.

Thanks in advance!

Comments