public String getContentType() { try { return content.getContentInfo().getContentType(); } catch (FileSystemException e) { throw new RuntimeException(e.getMessage()); } }
/** * Finds the provider to use to create a filesystem from a given file. */ public String getScheme(final FileObject file) throws FileSystemException { // Check the file's mime type for a match final FileContent content = file.getContent(); // final String mimeType = (String) content.getAttribute("content-type"); final String mimeType = content.getContentInfo().getContentType(); if (mimeType != null) { return (String) mimeTypeMap.get(mimeType); } // Check the file's extension for a match final String extension = file.getName().getExtension(); return (String) extensionMap.get(extension); } }
public Object execute(final CommandContext context) throws Exception { assert context != null; IO io = context.getIo(); // // TODO: Support multi-path cat, and the special '-' token (which is the default if no paths are given) // FileObject file = resolveFile(context, path); ensureFileExists(file); ensureFileHasContent(file); FileContent content = file.getContent(); FileContentInfo info = content.getContentInfo(); log.debug("Content type: {}", info.getContentType()); log.debug("Content encoding: {}", info.getContentEncoding()); // // TODO: Only cat files which we think are text, or warn if its not, allow flag to force // log.debug("Displaying file: {}", file.getName()); BufferedReader reader = new BufferedReader(new InputStreamReader(content.getInputStream())); try { cat(reader, io); } finally { Closer.close(reader); } FileObjects.close(file); return CommandAction.Result.SUCCESS; }
public Object execute(final CommandContext context) throws Exception { assert context != null; IO io = context.getIo(); // // TODO: Support multi-path cat, and the special '-' token (which is the default if no paths are given) // FileObject file = resolveFile(context, path); new FileObjectAssert(file).exists(); ensureFileHasContent(file); org.apache.commons.vfs.FileContent content = file.getContent(); FileContentInfo info = content.getContentInfo(); log.debug("Content type: {}", info.getContentType()); log.debug("Content encoding: {}", info.getContentEncoding()); // // TODO: Only cat files which we think are text, or warn if its not, allow flag to force // log.debug("Displaying file: {}", file.getName()); BufferedReader reader = new BufferedReader(new InputStreamReader(content.getInputStream())); try { cat(reader, io); } finally { Closer.close(reader); } FileObjects.close(file); return Result.SUCCESS; }
FileContent content = file.getContent(); FileContentInfo contentInfo = content.getContentInfo(); io.info("Content type: {}", contentInfo.getContentType()); io.info("Content encoding: {}", contentInfo.getContentEncoding());
FileContent content = file.getContent(); FileContentInfo contentInfo = content.getContentInfo(); io.info("Content type: {}", contentInfo.getContentType()); io.info("Content encoding: {}", contentInfo.getContentEncoding());