aboutsummaryrefslogtreecommitdiff
path: root/juick-common/src/main
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-04-03 17:55:46 +0300
committerGravatar Vitaly Takmazov2018-04-03 17:55:54 +0300
commita5f045a3780ef8530afa7493cf090771b8fdcfe1 (patch)
tree56e4cbc6949dc9bd39672ccf379324338f0eef76 /juick-common/src/main
parentc53675e5eb19a1a05ae5edcd0322075d51628b96 (diff)
refactoring: all messages are processed with XMPPConnection
Diffstat (limited to 'juick-common/src/main')
-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;