mimeType= URLConnection.guessContentTypeFromName(file.getName());
@Override public String getType(Uri uri) { return(URLConnection.guessContentTypeFromName(uri.toString())); }
@Override public String getType(Uri uri) { return(URLConnection.guessContentTypeFromName(uri.toString())); }
@Override public String getType(Uri uri) { return(URLConnection.guessContentTypeFromName(uri.toString())); }
writer.append("Content-Type: " + URLConnection.guessContentTypeFromName(binaryFile.getName())).append(CRLF); writer.append("Content-Transfer-Encoding: binary").append(CRLF); writer.append(CRLF).flush();
/** * Sets the content type header for the HTTP Response * * @param response HTTP response * @param file file to extract content type */ private static void setContentTypeHeader(HttpResponse response, File file) { String contentType = StringKit.mimeType(file.getName()); if (null == contentType) { contentType = URLConnection.guessContentTypeFromName(file.getName()); } response.headers().set(HttpConst.CONTENT_TYPE, contentType); }
@Signature public static String guessContentTypeFromName(String fname) { return URLConnection.guessContentTypeFromName(fname); }
/** * Sets the content type header for the HTTP Response * * @param response HTTP response * @param file file to extract content type */ private static void setContentTypeHeader(HttpResponse response, File file) { String contentType = StringKit.mimeType(file.getName()); if (null == contentType) { contentType = URLConnection.guessContentTypeFromName(file.getName()); } response.headers().set(HttpConst.CONTENT_TYPE, contentType); }
contentType = URLConnection.guessContentTypeFromName(imagePath);
@Nullable static MediaType guessFromPath(String path) { requireNonNull(path, "path"); final int dotIdx = path.lastIndexOf('.'); final int slashIdx = path.lastIndexOf('/'); if (dotIdx < 0 || slashIdx > dotIdx) { // No extension return null; } final String extension = Ascii.toLowerCase(path.substring(dotIdx + 1)); final MediaType mediaType = EXTENSION_TO_MEDIA_TYPE.get(extension); if (mediaType != null) { return mediaType; } final String guessedContentType = URLConnection.guessContentTypeFromName(path); return guessedContentType != null ? MediaType.parse(guessedContentType) : null; }
@Override public void removeFile(String storeCode, String fileName) throws ServiceException { String fileType = "IMAGE"; String mimetype = URLConnection.guessContentTypeFromName(fileName); String type = mimetype.split("/")[0]; if(!type.equals("image")) fileType = "STATIC_FILE"; contentFileManager.removeFile( storeCode, FileContentType.valueOf(fileType), fileName); }
writer.append("Content-Type: " + URLConnection.guessContentTypeFromName(binaryFile.getName())).append(CRLF); writer.append("Content-Transfer-Encoding: binary").append(CRLF); writer.append(CRLF).flush();
/** * Returns an object representing the content of the resource this {@code * URLConnection} is connected to. First, it attempts to get the content * type from the method {@code getContentType()} which looks at the response * header field "Content-Type". If none is found it will guess the content * type from the filename extension. If that fails the stream itself will be * used to guess the content type. * * @return the content representing object. * @throws IOException * if an error occurs obtaining the content. */ public Object getContent() throws java.io.IOException { if (!connected) { connect(); } if ((contentType = getContentType()) == null) { if ((contentType = guessContentTypeFromName(url.getFile())) == null) { contentType = guessContentTypeFromStream(getInputStream()); } } if (contentType != null) { return getContentHandler(contentType).getContent(this); } return null; }
if ((contentType = guessContentTypeFromName(url.getFile())) == null) { contentType = guessContentTypeFromStream(getInputStream());
sb.append(asset.file.isDirectory() ? 0 : asset.file.length()); sb.append(":"); String mimetype = URLConnection.guessContentTypeFromName(asset.file.name()); sb.append(mimetype == null ? "application/unknown" : mimetype); sb.append("\n");
sb.append(asset.file.isDirectory() ? 0 : asset.file.length()); sb.append(":"); String mimetype = URLConnection.guessContentTypeFromName(asset.file.name()); sb.append(mimetype == null ? "application/unknown" : mimetype); sb.append("\n");
files = new ArrayList<OutputContentFile>(); String mimetype = URLConnection.guessContentTypeFromName(os.getKey()); if (!StringUtils.isBlank(mimetype)) { S3Object o = s3.getObject(bucketName, os.getKey());
/** * Method responsible for adding content file for given merchant store in underlying Infinispan tree * cache. It will take {@link InputContentFile} and will store file for given merchant store according to its type. * it can save an image or any type of file (pdf, css, js ...) * @param merchantStoreCode Merchant store * @param contentFile {@link InputContentFile} being stored * @throws ServiceException service exception */ @Override public void addContentFile( String merchantStoreCode, InputContentFile contentFile ) throws ServiceException { Assert.notNull( merchantStoreCode, "Merchant store Id can not be null" ); Assert.notNull( contentFile, "InputContentFile image can not be null" ); Assert.notNull( contentFile.getFileName(), "InputContentFile.fileName can not be null" ); Assert.notNull( contentFile.getFileContentType(), "InputContentFile.fileContentType can not be null" ); String mimeType = URLConnection.guessContentTypeFromName(contentFile.getFileName()); contentFile.setMimeType(mimeType); if(contentFile.getFileContentType().name().equals(FileContentType.IMAGE.name()) || contentFile.getFileContentType().name().equals(FileContentType.STATIC_FILE.name())) { addFile(merchantStoreCode,contentFile); } else { addImage(merchantStoreCode,contentFile); } }
files = new ArrayList<OutputContentFile>(); String mimetype = URLConnection.guessContentTypeFromName(os.getKey()); if (!StringUtils.isBlank(mimetype)) { S3Object o = s3.getObject(bucketName, os.getKey());
fileNames = new ArrayList<String>(); String mimetype = URLConnection.guessContentTypeFromName(os.getKey()); if (!StringUtils.isBlank(mimetype)) { fileNames.add(getName(os.getKey()));