code: public static Attachment fromBinaryBytes( byte[] bytes, MediaType mediaType ) {
          if( !mediaType.isBinary() ) {
              throw new IllegalArgumentException( "MediaType must be binary" );
          }
          return new Attachment(BaseEncoding.base64().encode( bytes ), mediaType, null );
      }
docs: Creates an attachment from a given array of bytes.
  The bytes will be Base64 encoded.
  @throws java.lang.IllegalArgumentException if mediaType is not binary