mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-02 20:40:38 +00:00
Dirty hack to fix mime-type for webps
This commit is contained in:
parent
6c29d90503
commit
a4efa03dce
1 changed files with 9 additions and 0 deletions
|
@ -14,10 +14,19 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Optional;
|
||||
|
||||
public class Utils {
|
||||
public static Optional<String> getExtensionByStringHandling(String filename) {
|
||||
return Optional.ofNullable(filename)
|
||||
.filter(f -> f.contains("."))
|
||||
.map(f -> f.substring(filename.lastIndexOf(".") + 1));
|
||||
}
|
||||
|
||||
public static String getFileMimeType(File file, String defaultMimeType) throws IOException {
|
||||
if (getExtensionByStringHandling(file.toPath().toString()).get().equals("webp")) {
|
||||
return "image/webp";
|
||||
}
|
||||
var mime = Files.probeContentType(file.toPath());
|
||||
if (mime == null) {
|
||||
try (InputStream bufferedStream = new BufferedInputStream(new FileInputStream(file))) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue