From 3069c76cc870fded9bef581a218b68fa4e38fd49 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 11 Nov 2016 15:34:38 +0300 Subject: xmpp-ft: fix target filename --- .../src/main/java/com/juick/components/XMPPFTServer.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'juick-xmpp-ft/src/main/java') diff --git a/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java b/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java index 05f2b465..e922e7fa 100644 --- a/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java +++ b/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java @@ -57,8 +57,11 @@ public class XMPPFTServer { try { List allowedTypes = new ArrayList() {{ add("png"); add("jpg"); }}; String attachmentExtension = FilenameUtils.getExtension(e.getName()); + String targetFilename = String.format("%s.%s", + DigestUtils.md5Hex(String.format("%s-%s", + e.getInitiator().toString(), e.getSessionId()).getBytes()), attachmentExtension); if (allowedTypes.contains(attachmentExtension)) { - Path filePath = Paths.get(tmpDir, e.getName()); + Path filePath = Paths.get(tmpDir, targetFilename); FileTransfer ft = e.accept(filePath).get(); ft.addFileTransferStatusListener(st -> { logger.debug(String.format("%s: received %d of %d", e.getName(), st.getBytesTransferred(), e.getSize())); @@ -70,10 +73,7 @@ public class XMPPFTServer { msg.setTo(Jid.of(juickJid)); msg.setBody(e.getDescription()); try { - String attachmentUrl = String.format("juick://%s.%s", - DigestUtils.md5Hex(String.format("%s-%s", - e.getInitiator().toString(), e.getSessionId()).getBytes()), - attachmentExtension); + String attachmentUrl = String.format("juick://%s", targetFilename); msg.addExtension(new OobX(new URI(attachmentUrl).toURL(), "!!!!Juick!!")); component.sendMessage(msg); } catch (MalformedURLException | URISyntaxException e1) { -- cgit v1.2.3