diff options
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); |