diff options
author | Vitaly Takmazov | 2018-10-05 12:38:19 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-10-05 12:38:19 +0300 |
commit | 2379429b534ff5d93cb54f835e95a059fa5f3fc9 (patch) | |
tree | 42874e32185977ef50c7efbe14d71c1764d183af /juick-server/src/main/java/com/juick/server/util | |
parent | 0a67254245046236f82733c95e84a23ffcfdc45c (diff) |
ActivityPub: forward attachment as Image
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/util')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/util/HttpUtils.java | 5 |
1 files changed, 5 insertions, 0 deletions
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<ImageReader> readers = ImageIO.getImageReaders(iis); |