String jsonMetadata = null;
// iterate over the body parts and pick out the "photo" and "metadata" parts
for (final BodyPart bodyPart : multiPart.getBodyParts()) {
final ContentDisposition contentDisposition = bodyPart.getContentDisposition();
if (contentDisposition != null) {
final Map<String, String> parameters = contentDisposition.getParameters();
if (parameters != null) {
final String name = parameters.get("name");
if ("photo".equals(name)) {
// found the photo part
final BodyPartEntity bodyPartEntity = (BodyPartEntity)bodyPart.getEntity();