@Test public void testGetContentType() throws Exception { final DefaultEmailAttachment emailAttachment = getDefaultEmailAttachment(); final MediaType mediaType = emailAttachment.getContentType(); assertThat(mediaType, not(is(nullValue()))); assertThat(mediaType, is(IMAGE_JPEG)); }
public MediaType getContentType() throws IOException { final InputStream attachmentDataStream = new ByteArrayInputStream(attachmentData); final MediaType mediaType; try { mediaType = ofNullable(this.mediaType) .orElse(TikaDetector.tikaDetector().detect(attachmentDataStream, attachmentName)); } catch (IOException e) { log.error("The MimeType is not set. Tried to guess it but something went wrong.", e); throw e; } return mediaType; }
DefaultEmailAttachment implements EmailAttachment { public MediaType getContentType() throws IOException { final InputStream attachmentDataStream = new ByteArrayInputStream(attachmentData); final MediaType mediaType; try { mediaType = ofNullable(this.mediaType) .orElse(TikaDetector.tikaDetector().detect(attachmentDataStream, attachmentName)); } catch (IOException e) { log.error("The MimeType is not set. Tried to guess it but something went wrong.", e); throw e; } return mediaType; } }
DefaultEmailAttachment implements EmailAttachment { public MediaType getContentType() throws IOException { final InputStream attachmentDataStream = new ByteArrayInputStream(attachmentData); final MediaType mediaType; try { mediaType = ofNullable(this.mediaType) .orElse(TikaDetector.tikaDetector().detect(attachmentDataStream, attachmentName)); } catch (IOException e) { log.error("The MimeType is not set. Tried to guess it but something went wrong.", e); throw e; } return mediaType; }  }
DefaultEmailAttachment implements EmailAttachment { public MediaType getContentType() throws IOException { final InputStream attachmentDataStream = new ByteArrayInputStream(attachmentData); final MediaType mediaType; try { mediaType = ofNullable(this.mediaType) .orElse(TikaDetector.tikaDetector().detect(attachmentDataStream, attachmentName)); } catch (IOException e) { log.error("The MimeType is not set. Tried to guess it but something went wrong.", e); throw e; } return mediaType; }  MediaType getContentType(); }
DefaultEmailAttachment implements EmailAttachment { public MediaType getContentType() throws IOException { final InputStream attachmentDataStream = new ByteArrayInputStream(attachmentData); final MediaType mediaType; try { mediaType = ofNullable(this.mediaType) .orElse(TikaDetector.tikaDetector().detect(attachmentDataStream, attachmentName)); } catch (IOException e) { log.error("The MimeType is not set. Tried to guess it but something went wrong.", e); throw e; } return mediaType; }  MediaType getContentType();  }