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 { WebdavFileObject file = (WebdavFileObject) (FileObjectUtils.getAbstractFileObject(fileContent.getFile())); String contentType = null; String contentEncoding = null; DavPropertyNameSet nameSet = new DavPropertyNameSet(); nameSet.add(DavPropertyName.GETCONTENTTYPE); DavPropertySet propertySet = file.getProperties((URLFileName) file.getName(), nameSet, true); DavProperty property = propertySet.get(DavPropertyName.GETCONTENTTYPE); if (property != null) { contentType = (String) property.getValue(); } property = propertySet.get(WebdavFileObject.RESPONSE_CHARSET); if (property != null) { contentEncoding = (String) property.getValue(); } return new DefaultFileContentInfo(contentType, contentEncoding); }