diff --git a/src/main/java/com/contentstack/cms/stack/FileUploader.java b/src/main/java/com/contentstack/cms/stack/FileUploader.java index df0f6d16..8b28c150 100644 --- a/src/main/java/com/contentstack/cms/stack/FileUploader.java +++ b/src/main/java/com/contentstack/cms/stack/FileUploader.java @@ -6,9 +6,11 @@ import java.io.File; import java.io.IOException; -import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Objects; +import javax.activation.MimetypesFileTypeMap; + public class FileUploader { @@ -49,7 +51,9 @@ private void addFormDataPartIfNotNull(MultipartBody.Builder builder, String name // Helper method to get content type of file private String getContentType(File file) { try { - return Files.probeContentType(file.toPath()); + java.nio.file.Path source = Paths.get(file.toString()); + MimetypesFileTypeMap m = new MimetypesFileTypeMap(source.toString()); + return m.getContentType(file); } catch (IOException e) { throw new RuntimeException("Failed to determine content type of file", e); }