Skip to content

Commit aad2572

Browse files
Vikram KaltaVikram Kalta
authored andcommitted
fix: fixed null content type issue
1 parent 3293661 commit aad2572

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/com/contentstack/cms/stack/FileUploader.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
import java.io.File;
88
import java.io.IOException;
9-
import java.nio.file.Files;
9+
import java.nio.file.Paths;
1010
import java.util.Objects;
1111

12+
import javax.activation.MimetypesFileTypeMap;
13+
1214
public class FileUploader {
1315

1416

@@ -49,7 +51,9 @@ private void addFormDataPartIfNotNull(MultipartBody.Builder builder, String name
4951
// Helper method to get content type of file
5052
private String getContentType(File file) {
5153
try {
52-
return Files.probeContentType(file.toPath());
54+
java.nio.file.Path source = Paths.get(file.toString());
55+
MimetypesFileTypeMap m = new MimetypesFileTypeMap(source.toString());
56+
return m.getContentType(file);
5357
} catch (IOException e) {
5458
throw new RuntimeException("Failed to determine content type of file", e);
5559
}

0 commit comments

Comments
 (0)