public static StreamDetails createStreamDetailsFromFile(File file) throws IOException {
InputStream stream = new FileInputStream(file);
final long size = file.length();
- String mime = Files.probeContentType(file.toPath());
- if (mime == null) {
- mime = "application/octet-stream";
- }
+ final String mime = getFileMimeType(file, "application/octet-stream");
return new StreamDetails(stream, mime, size);
}
public static JsonNode getNotNullNode(JsonNode parent, String name) throws InvalidObjectException {
JsonNode node = parent.get(name);
- if (node == null) {
+ if (node == null || node.isNull()) {
throw new InvalidObjectException(String.format("Incorrect file format: expected parameter %s not found ",
name));
}