/** * Creates a FileContentInfo for a the given FileContent. * * @param fileContent Use this FileContent to create a matching FileContentInfo * @return a FileContentInfo for the given FileContent with content set to "text/plain" and encoding set to "UTF-8" * @throws FileSystemException when a problem occurs creating the FileContentInfo. */ @Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { return new DefaultFileContentInfo(CONTENT, ENCODING); }
/** * Creates a FileContentInfo for a the given FileContent. * * @param fileContent Use this FileContent to create a matching FileContentInfo * @return a FileContentInfo for the given FileContent with content set to "text/plain" and encoding set to "UTF-8" * @throws FileSystemException when a problem occurs creating the FileContentInfo. */ @Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { return new DefaultFileContentInfo(CONTENT, ENCODING); }
/** * Creates a FileContentInfo for a the given FileContent. * * @param fileContent Use this FileContent to create a matching FileContentInfo * @return a FileContentInfo for the given FileContent with content set to "text/plain" and encoding set to "UTF-8" * @throws FileSystemException when a problem occurs creating the FileContentInfo. */ @Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { return new DefaultFileContentInfo(CONTENT, ENCODING); }
@Override public FileContentInfo create(final FileContent fileContent) { String contentType = null; final String name = fileContent.getFile().getName().getBaseName(); if (name != null) { final FileNameMap fileNameMap = URLConnection.getFileNameMap(); contentType = fileNameMap.getContentTypeFor(name); } return new DefaultFileContentInfo(contentType, null); } }
@Override public FileContentInfo create(final FileContent fileContent) { String contentType = null; final String name = fileContent.getFile().getName().getBaseName(); if (name != null) { final FileNameMap fileNameMap = URLConnection.getFileNameMap(); contentType = fileNameMap.getContentTypeFor(name); } return new DefaultFileContentInfo(contentType, null); } }
@Override public FileContentInfo create(final FileContent fileContent) { String contentType = null; final String name = fileContent.getFile().getName().getBaseName(); if (name != null) { final FileNameMap fileNameMap = URLConnection.getFileNameMap(); contentType = fileNameMap.getContentTypeFor(name); } return new DefaultFileContentInfo(contentType, null); } }
@SuppressWarnings("unchecked") @Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { String contentMimeType = null; String contentCharset = null; try (final Http4FileObject<Http4FileSystem> http4File = (Http4FileObject<Http4FileSystem>) FileObjectUtils .getAbstractFileObject(fileContent.getFile())) { final HttpResponse lastHeadResponse = http4File.getLastHeadResponse(); final Header header = lastHeadResponse.getFirstHeader(HTTP.CONTENT_TYPE); if (header != null) { final ContentType contentType = ContentType.parse(header.getValue()); contentMimeType = contentType.getMimeType(); if (contentType.getCharset() != null) { contentCharset = contentType.getCharset().name(); } } return new DefaultFileContentInfo(contentMimeType, contentCharset); } catch (final IOException e) { throw new FileSystemException(e); } } }
@Override public FileContentInfo create(final FileContent fileContent) { String contentType = null; final String name = fileContent.getFile().getName().getBaseName(); if (name != null) { final FileNameMap fileNameMap = URLConnection.getFileNameMap(); contentType = fileNameMap.getContentTypeFor(name); } return new DefaultFileContentInfo(contentType, null); } }
@Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { final HttpFileObject httpFile = (HttpFileObject) FileObjectUtils.getAbstractFileObject(fileContent.getFile()); String contentType = null; String contentEncoding = null; HeadMethod headMethod; try { headMethod = httpFile.getHeadMethod(); } catch (final IOException e) { throw new FileSystemException(e); } final Header header = headMethod.getResponseHeader("content-type"); if (header != null) { final HeaderElement[] element = header.getElements(); if (element != null && element.length > 0) { contentType = element[0].getName(); } } contentEncoding = headMethod.getResponseCharSet(); return new DefaultFileContentInfo(contentType, contentEncoding); } }
@Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { String contentType = null; String contentEncoding = null; HeadMethod headMethod; try (final HttpFileObject<HttpFileSystem> httpFile = (HttpFileObject<HttpFileSystem>) FileObjectUtils .getAbstractFileObject(fileContent.getFile())) { headMethod = httpFile.getHeadMethod(); } catch (final IOException e) { throw new FileSystemException(e); } final Header header = headMethod.getResponseHeader("content-type"); if (header != null) { final HeaderElement[] element = header.getElements(); if (element != null && element.length > 0) { contentType = element[0].getName(); } } contentEncoding = headMethod.getResponseCharSet(); return new DefaultFileContentInfo(contentType, contentEncoding); } }
@Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { final HttpFileObject httpFile = (HttpFileObject) FileObjectUtils.getAbstractFileObject(fileContent.getFile()); String contentType = null; String contentEncoding = null; HeadMethod headMethod; try { headMethod = httpFile.getHeadMethod(); } catch (final IOException e) { throw new FileSystemException(e); } final Header header = headMethod.getResponseHeader("content-type"); if (header != null) { final HeaderElement[] element = header.getElements(); if (element != null && element.length > 0) { contentType = element[0].getName(); } } contentEncoding = headMethod.getResponseCharSet(); return new DefaultFileContentInfo(contentType, contentEncoding); } }
@Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { final WebdavFileObject file = (WebdavFileObject) FileObjectUtils.getAbstractFileObject(fileContent.getFile()); String contentType = null; String contentEncoding = null; final DavPropertyNameSet nameSet = new DavPropertyNameSet(); nameSet.add(DavPropertyName.GETCONTENTTYPE); final 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); } }
@Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { final WebdavFileObject file = (WebdavFileObject) FileObjectUtils.getAbstractFileObject(fileContent.getFile()); String contentType = null; String contentEncoding = null; final DavPropertyNameSet nameSet = new DavPropertyNameSet(); nameSet.add(DavPropertyName.GETCONTENTTYPE); final 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); } }
@Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { final WebdavFileObject file = (WebdavFileObject) FileObjectUtils.getAbstractFileObject(fileContent.getFile()); String contentType = null; String contentEncoding = null; final DavPropertyNameSet nameSet = new DavPropertyNameSet(); nameSet.add(DavPropertyName.GETCONTENTTYPE); final 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); } }
return new DefaultFileContentInfo(contentType.getBaseType(), charset);
return new DefaultFileContentInfo( contentType.getBaseType(), charset);