/** * Creates dss document that retains the data in memory * * @param bytes * array of bytes representing the document * @param name * the file name if the data originates from a file */ public InMemoryDocument(final byte[] bytes, final String name) { this.bytes = bytes; this.name = name; this.mimeType = MimeType.fromFileName(name); }
/** * Create a FileDocument * * @param file * {@code File} */ public FileDocument(final File file) { if (file == null) { throw new NullPointerException(); } if (!file.exists()) { throw new DSSException("File Not Found: " + file.getAbsolutePath()); } this.file = file; this.name = file.getName(); this.mimeType = MimeType.fromFileName(file.getName()); }
protected String getDataFileMimeType(String fileName) { if (manifestFileItems.containsKey(fileName)) { ManifestEntry manifestEntry = manifestFileItems.get(fileName); return manifestEntry.getMimeType(); } else { MimeType mimetype = MimeType.fromFileName(fileName); return mimetype.getMimeTypeString(); } }
private String getMimeType(String documentPath) { String mimeType = this.commandLineExecutor.getContext().getCommandLine().getOptionValue("mimeType"); if (StringUtils.isNotBlank(mimeType)) { return mimeType; } return MimeType.fromFileName(documentPath).getMimeTypeString(); }
DSSDocument createDssDocument(final ValidationDocument validationDocument) { if (validationDocument == null) { return null; } final InMemoryDocument dssDocument = new InMemoryDocument(validationDocument.getBytes()); dssDocument.setName(validationDocument.getName()); dssDocument.setMimeType(MimeType.fromFileName(validationDocument.getName())); return dssDocument; }