I use multipartRequest for this. All you have to do is pass in the request and the number of bytes allowed for the attachment.