code: private byte[] buildMultipartBody(Map<String, String> params, byte[] photoData, String boundary) throws JinxException {
  
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      try {
        String filename = params.get("filename");
        if (JinxUtils.isNullOrEmpty(filename)) {
          filename = "image.jpg";
        }
        String fileMimeType = params.get("filemimetype");
        if (JinxUtils.isNullOrEmpty(fileMimeType)) {
          fileMimeType = "image/jpeg";
        }
  
        buffer.write(("--" + boundary + "\r\n").getBytes(JinxConstants.UTF8));
        for (Map.Entry<String, String> entry : params.entrySet()) {
          String key = entry.getKey();
          if (!key.equals("filename") && !key.equals("filemimetype")) {
  
            buffer.write(("Content-Disposition: form-data; name=\"" + key + "\"\r\n\r\n").getBytes(JinxConstants.UTF8));
            buffer.write((entry.getValue()).getBytes(JinxConstants.UTF8));
            buffer.write(("\r\n" + "--" + boundary + "\r\n").getBytes(JinxConstants.UTF8));
          }
        }
        buffer.write(("Content-Disposition: form-data; name=\"photo\"; filename=\"" + filename + "\";\r\n").getBytes(JinxConstants.UTF8));
        buffer.write(("Content-Type: " + fileMimeType + "\r\n\r\n").getBytes(JinxConstants.UTF8));
        buffer.write(photoData);
        buffer.write(("\r\n" + "--" + boundary + "--\r\n").getBytes(JinxConstants.UTF8));   // NOTE: last boundary has -- suffix
  
      } catch (Exception e) {
        throw new JinxException("Unable to build multipart body.", e);
      }
  
      if (this.isVerboseLogging() && this.isMultipartLogging()) {
        JinxLogger.getLogger().log("Multipart body: " + buffer.toString());
      }
  
      return buffer.toByteArray();
    }
docs: /*
  Build a multipart body request.