- static SignalServiceAttachmentStream createAttachment(File attachmentFile) throws IOException {
- InputStream attachmentStream = new FileInputStream(attachmentFile);
- final long attachmentSize = attachmentFile.length();
- String mime = Files.probeContentType(attachmentFile.toPath());
+ private static String getFileMimeType(File file) throws IOException {
+ String mime = Files.probeContentType(file.toPath());
+ if (mime == null) {
+ try (InputStream bufferedStream = new BufferedInputStream(new FileInputStream(file))) {
+ mime = URLConnection.guessContentTypeFromStream(bufferedStream);
+ }
+ }