aboutsummaryrefslogtreecommitdiff
path: root/juick-common/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'juick-common/src/main/java/com')
-rw-r--r--juick-common/src/main/java/com/juick/server/util/HttpUtils.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/juick-common/src/main/java/com/juick/server/util/HttpUtils.java b/juick-common/src/main/java/com/juick/server/util/HttpUtils.java
index 35f594f3..f86e52c5 100644
--- a/juick-common/src/main/java/com/juick/server/util/HttpUtils.java
+++ b/juick-common/src/main/java/com/juick/server/util/HttpUtils.java
@@ -24,6 +24,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
@@ -37,7 +38,7 @@ import java.util.UUID;
public class HttpUtils {
private static final Logger logger = LoggerFactory.getLogger(HttpUtils.class);
- public static String receiveMultiPartFile(MultipartFile attach, String tmpDir) {
+ public static URI receiveMultiPartFile(MultipartFile attach, String tmpDir) {
if (attach !=null && !attach.isEmpty()) {
String partname = attach.getOriginalFilename();
if (partname != null && partname.length() > 0) {
@@ -50,16 +51,16 @@ public class HttpUtils {
try {
Files.write(Paths.get(tmpDir, attachmentFName),
attach.getBytes());
- return attachmentFName;
+ return URI.create(String.format("juick://%s", attachmentFName));
} catch (IOException e) {
logger.warn("file receive error", e);
}
}
}
}
- return StringUtils.EMPTY;
+ return URI.create("");
}
- public static String downloadImage(URL url, String tmpDir) throws Exception {
+ public static URI downloadImage(URL url, String tmpDir) throws Exception {
URLConnection urlConn;
try {
urlConn = url.openConnection();
@@ -86,7 +87,7 @@ public class HttpUtils {
String attachmentFName = DigestUtils.md5Hex(UUID.randomUUID().toString()) + "." + attachmentType;
Files.copy(is, Paths.get(tmpDir, attachmentFName));
- return attachmentFName;
+ return URI.create(String.format("juick://%s", attachmentFName));
} catch (Exception e) {
logger.error(String.format("Failed download image by url: %s", url.toString()), e);
throw e;