From 2379429b534ff5d93cb54f835e95a059fa5f3fc9 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 5 Oct 2018 12:38:19 +0300 Subject: ActivityPub: forward attachment as Image --- juick-server/src/main/java/com/juick/server/util/HttpUtils.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'juick-server/src/main/java/com/juick/server/util') diff --git a/juick-server/src/main/java/com/juick/server/util/HttpUtils.java b/juick-server/src/main/java/com/juick/server/util/HttpUtils.java index 9f356aa5..b70eb3ad 100644 --- a/juick-server/src/main/java/com/juick/server/util/HttpUtils.java +++ b/juick-server/src/main/java/com/juick/server/util/HttpUtils.java @@ -20,6 +20,7 @@ import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.http.MediaType; import org.springframework.web.multipart.MultipartFile; import javax.imageio.ImageIO; @@ -79,6 +80,10 @@ public class HttpUtils { } } + public static String mediaType(String attachmentType) { + return attachmentType.equals("jpg") ? MediaType.IMAGE_JPEG_VALUE : MediaType.IMAGE_PNG_VALUE; + } + public static URI downloadImage(URL url, String tmpDir) throws IOException { ImageInputStream iis = ImageIO.createImageInputStream(url.openStream()); Iterator readers = ImageIO.getImageReaders(iis); -- cgit v1.2.3