public <R extends MediaSource> R parse(ParseSource parseSource, InputProperties inProps, Class<R> resultClass) { // Ensure that the expected result type is MediaSource Preconditions.checkArgument(resultClass.isAssignableFrom(MediaSource.class), "Result class must be " + MediaSource.class.getName()); InputStream inputStream = parseSource.getInputStream(); Preconditions.checkNotNull(inputStream, "Parse source must be stream-based"); MediaStreamSource mediaSource = new MediaStreamSource(inputStream, inProps.getContentType().toString()); return resultClass.cast(mediaSource); } }
public <R extends MediaSource> R parse(ParseSource parseSource, InputProperties inProps, Class<R> resultClass) { // Ensure that the expected result type is MediaSource Preconditions.checkArgument(resultClass.isAssignableFrom(MediaSource.class), "Result class must be " + MediaSource.class.getName()); InputStream inputStream = parseSource.getInputStream(); Preconditions.checkNotNull(inputStream, "Parse source must be stream-based"); MediaStreamSource mediaSource = new MediaStreamSource(inputStream, inProps.getContentType().toString()); return resultClass.cast(mediaSource); } }
public MediaBodyPart(InternetHeaders headers, byte [] content) throws MessagingException { super(headers, content); // javax.mail.util.SharedByteArrayInputStream here. String contentType = getContentType(); MediaStreamSource mediaStreamSource = new MediaStreamSource(new ByteArrayInputStream(content), contentType); String etag = getHeader(GDataProtocol.Header.ETAG, null); if (etag != null) { mediaStreamSource.setEtag(etag); } mediaSource = mediaStreamSource; initMediaDataHandler(); }
public MediaBodyPart(InternetHeaders headers, byte [] content) throws MessagingException { super(headers, content); // javax.mail.util.SharedByteArrayInputStream here. String contentType = getContentType(); MediaStreamSource mediaStreamSource = new MediaStreamSource(new ByteArrayInputStream(content), contentType); String etag = getHeader(GDataProtocol.Header.ETAG, null); if (etag != null) { mediaStreamSource.setEtag(etag); } mediaSource = mediaStreamSource; initMediaDataHandler(); }
public MediaBodyPart(InputStream is) throws MessagingException { // Process the headers from the input stream super(new InternetHeaders(is), null); // Create a media stream source to read the remaining data, using the // content type information from the headers. mediaSource = new MediaStreamSource(is, getContentType()); initMediaDataHandler(); }
public MediaBodyPart(InputStream is) throws MessagingException { // Process the headers from the input stream super(new InternetHeaders(is), null); // Create a media stream source to read the remaining data, using the // content type information from the headers. mediaSource = new MediaStreamSource(is, getContentType()); initMediaDataHandler(); }
/** * Constructs a new MediaMultipart instance by parsing MIME content from * the provided input stream. */ public MediaMultipart(String contentType, InputStream inputStream) throws MessagingException { // Construct a DataSource and pass it to the parent constructor. super(new MediaStreamSource(inputStream, contentType)); // Validate message content. if (getCount() != 2) { throw new MessagingException("Multipart must have Atom and media part"); } boolean atomFirst = getBodyPart(0).isMimeType(ContentType.ATOM.getMediaType()); if (!atomFirst && !getBodyPart(1).isMimeType(ContentType.ATOM.getMediaType())) { throw new MessagingException("No Atom MIME body part found"); } atomPart = (MediaBodyPart)getBodyPart(atomFirst ? 0 : 1); mediaPart = (MediaBodyPart)getBodyPart(atomFirst ? 1 : 0); }
/** * Constructs a new MediaMultipart instance by parsing MIME content from * the provided input stream. */ public MediaMultipart(String contentType, InputStream inputStream) throws MessagingException { // Construct a DataSource and pass it to the parent constructor. super(new MediaStreamSource(inputStream, contentType)); // Validate message content. if (getCount() != 2) { throw new MessagingException("Multipart must have Atom and media part"); } boolean atomFirst = getBodyPart(0).isMimeType(ContentType.ATOM.getMediaType()); if (!atomFirst && !getBodyPart(1).isMimeType(ContentType.ATOM.getMediaType())) { throw new MessagingException("No Atom MIME body part found"); } atomPart = (MediaBodyPart)getBodyPart(atomFirst ? 0 : 1); mediaPart = (MediaBodyPart)getBodyPart(atomFirst ? 1 : 0); }
InputStream resultStream = request.getResponseStream(); mediaSource = new MediaStreamSource(resultStream, request.getResponseContentType().toString());
InputStream resultStream = request.getResponseStream(); mediaSource = new MediaStreamSource(resultStream, request.getResponseContentType().toString());