/** * Constructor to create an object. * * @param name Parameter name to bind in the multipart request * @param filename Name of the file * @param contentType The type of the content, example - "application/json", "text/plain" etc */ AbstractFilePart(String name, String filename, @Nullable MediaType contentType) { super(name); if (filename == null) { throw new IllegalArgumentException("Adding file parts with a null filename is not allowed"); } this.filename = filename; if (contentType == null) { this.contentType = MediaType.forExtension(NameUtils.extension(filename)).orElse(MediaType.APPLICATION_OCTET_STREAM_TYPE); } else { this.contentType = contentType; } }
/** * Resolve the {@link MediaType} for the given file name. Defaults * to text/plain. * * @param filename The file name * @return The {@link MediaType} */ public static MediaType forFilename(String filename) { if (StringUtils.isNotEmpty(filename)) { return forExtension(NameUtils.extension(filename)).orElse(MediaType.TEXT_PLAIN_TYPE); } return MediaType.TEXT_PLAIN_TYPE; }
/** * Constructor to create an object. * * @param name Parameter name to bind in the multipart request * @param filename Name of the file * @param contentType The type of the content, example - "application/json", "text/plain" etc */ AbstractFilePart(String name, String filename, @Nullable MediaType contentType) { super(name); if (filename == null) { throw new IllegalArgumentException("Adding file parts with a null filename is not allowed"); } this.filename = filename; if (contentType == null) { this.contentType = MediaType.forExtension(NameUtils.extension(filename)).orElse(MediaType.APPLICATION_OCTET_STREAM_TYPE); } else { this.contentType = contentType; } }
/** * Constructor to create an object. * * @param name Parameter name to bind in the multipart request * @param filename Name of the file * @param contentType The type of the content, example - "application/json", "text/plain" etc */ AbstractFilePart(String name, String filename, @Nullable MediaType contentType) { super(name); if (filename == null) { throw new IllegalArgumentException("Adding file parts with a null filename is not allowed"); } this.filename = filename; if (contentType == null) { this.contentType = MediaType.forExtension(NameUtils.extension(filename)).orElse(MediaType.APPLICATION_OCTET_STREAM_TYPE); } else { this.contentType = contentType; } }
list.forEach(filePath -> { if (!propertySourceLoaders.isEmpty()) { String extension = NameUtils.extension(filePath); String fileName = NameUtils.filename(filePath); Optional<PropertySourceLoader> propertySourceLoader = Optional.ofNullable(loaderByFormatMap.get(extension));
list.forEach(filePath -> { if (!propertySourceLoaders.isEmpty()) { String extension = NameUtils.extension(filePath); String fileName = NameUtils.filename(filePath); Optional<PropertySourceLoader> propertySourceLoader = Optional.ofNullable(loaderByFormatMap.get(extension));