// just to avoid concurrency issues if this arg is mutable
final ArrayList<AttachmentInput> myAttachments = Lists.newArrayList(attachments);
invoke(new Callable<Void>() {
@Override
public Void call() throws Exception {
final MultiPart multiPartInput = new MultiPart();
for (AttachmentInput attachment : myAttachments) {
BodyPart bp = new BodyPart(attachment.getInputStream(), MediaType.APPLICATION_OCTET_STREAM_TYPE);
FormDataContentDisposition.FormDataContentDispositionBuilder dispositionBuilder =
FormDataContentDisposition.name(FILE_ATTACHMENT_CONTROL_NAME);
dispositionBuilder.fileName(attachment.getFilename());
final FormDataContentDisposition formDataContentDisposition = dispositionBuilder.build();
bp.setContentDisposition(formDataContentDisposition);
multiPartInput.bodyPart(bp);
}
postFileMultiPart(multiPartInput, attachmentsUri);
return null;
}