metadata.setDescription(data.getDescription());
metadata.setFileName(data.getFileName());
metadata.setMimeType(data.getMimeType());
metadata.setTitle(data.getTitle());
Attachment att = (Attachment) Attachment.Factory.newInstance();
att.setAttachmentMetadata(metadata);
att.setPayloadUrl(attachment.getPayloadURL().toString());
return att;
}