Ejemplo n.º 1
0
  @Override
  public Header[] getRequestHeaders() {
    List<Header> headers = getRequestHeadersList();

    // Add authentication header.
    if (userName != null && passWord != null) {
      byte[] base64bytes = Base64.encode((userName + ":" + passWord).getBytes(), Base64.DEFAULT);
      String credentials = new String(base64bytes);
      headers.add(new BasicHeader(HEADER_AUTHORIZATION, HEADER_BASIC + " " + credentials));
    }

    return headers.toArray(new Header[headers.size()]);
  }
Ejemplo n.º 2
0
 private static String encodeToBase64(
     Bitmap image, Bitmap.CompressFormat compressFormat, int quality) {
   ByteArrayOutputStream byteArrayOS = new ByteArrayOutputStream();
   image.compress(compressFormat, quality, byteArrayOS);
   return Base64.encodeToString(byteArrayOS.toByteArray(), Base64.DEFAULT);
 }
Ejemplo n.º 3
0
  // Convert image to base64 for server sending.
  public String getImageBase64() {

    return Base64.encodeToString(photoByteArray, 0);
  }