Skip to content

Commit

Permalink
fix: fixed null content type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Vikram Kalta authored and Vikram Kalta committed Mar 20, 2024
1 parent 0816f83 commit 5315ff5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/com/contentstack/cms/stack/FileUploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {


Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 5315ff5

Please sign in to comment.