public STAGE sourceName(String name) { this.sourceName = name; if (null == mimeType) { mimeType = MimeType.findByFileExtension(S.fileExtension(sourceName)); } return me(); }
public STAGE sourceName(String name) { this.sourceName = name; if (null == mimeType) { mimeType = MimeType.findByFileExtension(S.fileExtension(sourceName)); } return me(); }
public STAGE contentType(String contentType) { MimeType type = MimeType.findByContentType(contentType); if (null == type) { type = MimeType.findByFileExtension(contentType); } if (null != type) { this.mimeType = type; } else { E.unexpected("Content type unrecognized: " + contentType); } return me(); }
public STAGE contentType(String contentType) { MimeType type = MimeType.findByContentType(contentType); if (null == type) { type = MimeType.findByFileExtension(contentType); } if (null != type) { this.mimeType = type; } else { E.unexpected("Content type unrecognized: " + contentType); } return me(); }
/** * Construct an SObject with key and file specified * * @see #of(String, File, Map) */ public static SObject of(String key, File file) { if (file.canRead() && file.isFile()) { SObject sobj = new FileSObject(key, file); String fileName = file.getName(); sobj.setAttribute(ATTR_FILE_NAME, file.getName()); String fileExtension = S.fileExtension(fileName); MimeType mimeType = MimeType.findByFileExtension(fileExtension); String type = null != mimeType ? mimeType.type() : null; sobj.setAttribute(ATTR_CONTENT_TYPE, type); sobj.setAttribute(ATTR_CONTENT_LENGTH, S.string(file.length())); return sobj; } else { return getInvalidObject(key, new IOException("File is a directory or not readable")); } }
/** * Construct an SObject with key and file specified * * @see #of(String, File, Map) */ public static SObject of(String key, File file) { if (file.canRead() && file.isFile()) { SObject sobj = new FileSObject(key, file); String fileName = file.getName(); sobj.setAttribute(ATTR_FILE_NAME, file.getName()); String fileExtension = S.fileExtension(fileName); MimeType mimeType = MimeType.findByFileExtension(fileExtension); String type = null != mimeType ? mimeType.type() : null; sobj.setAttribute(ATTR_CONTENT_TYPE, type); sobj.setAttribute(ATTR_CONTENT_LENGTH, S.string(file.length())); return sobj; } else { return getInvalidObject(key, new IOException("File is a directory or not readable")); } }
if (null != sourceName) { String suffix = S.fileExtension(sourceName); mimeType = MimeType.findByFileExtension(suffix);
if (null != sourceName) { String suffix = S.fileExtension(sourceName); mimeType = MimeType.findByFileExtension(suffix);