public FileContentInfo create(final FileContent content) throws FileSystemException { assert content != null; MetaFileObject file = (MetaFileObject)content.getFile(); MetaData data = file.getData(); return new DefaultFileContentInfo(data.getContentType(), data.getContentEncoding()); } }
public FileContentInfo create(final FileContent content) throws FileSystemException { assert content != null; MetaFileObject file = (MetaFileObject)content.getFile(); MetaData data = file.getData(); return new DefaultFileContentInfo(data.getContentType(), data.getContentEncoding()); } }
public FileContentInfo create(FileContent fileContent) { String contentType = null; String name = fileContent.getFile().getName().getBaseName(); if (name != null) { FileNameMap fileNameMap = URLConnection.getFileNameMap(); contentType = fileNameMap.getContentTypeFor(name); } return new DefaultFileContentInfo(contentType, null); } }
public FileContentInfo create(FileContent fileContent) throws FileSystemException { HttpFileObject httpFile = (HttpFileObject) fileContent.getFile(); String contentType = null; String contentEncoding = null; Header header = httpFile.getHeadMethod().getResponseHeader("content-type"); if (header != null) { HeaderElement[] element; try { element = header.getValues(); } catch (HttpException e) { throw new FileSystemException(e); } if (element != null && element.length > 0) { contentType = element[0].getName(); } } contentEncoding = httpFile.getHeadMethod().getResponseCharSet(); return new DefaultFileContentInfo(contentType, contentEncoding); } }