diff --git a/src/main/java/org/rostislav/quickdrop/service/FileService.java b/src/main/java/org/rostislav/quickdrop/service/FileService.java index 95a41cc..2ea3eeb 100644 --- a/src/main/java/org/rostislav/quickdrop/service/FileService.java +++ b/src/main/java/org/rostislav/quickdrop/service/FileService.java @@ -50,7 +50,7 @@ public class FileService { String uuid = UUID.randomUUID().toString(); Path path = Path.of(fileSavePath, uuid); - if (fileUploadRequest.password == null) { + if (fileUploadRequest.password == null || fileUploadRequest.password.isEmpty()) { if (!saveUnencryptedFile(file, path)) { return null; } @@ -67,7 +67,7 @@ public class FileService { fileEntity.size = file.getSize(); fileEntity.keepIndefinitely = fileUploadRequest.keepIndefinitely; - if (fileUploadRequest.password != null) { + if (fileUploadRequest.password != null && !fileUploadRequest.password.isEmpty()) { fileEntity.passwordHash = passwordEncoder.encode(fileUploadRequest.password); } diff --git a/src/main/resources/static/js/fileView.js b/src/main/resources/static/js/fileView.js new file mode 100644 index 0000000..e2b6b4c --- /dev/null +++ b/src/main/resources/static/js/fileView.js @@ -0,0 +1,10 @@ +function copyToClipboard() { + const copyText = document.getElementById("downloadLink"); + const copyButton = document.querySelector(".copyButton"); + navigator.clipboard.writeText(copyText.value).then(function () { + copyButton.innerText = "Copied!"; + copyButton.classList.add("btn-success"); + }).catch(function (err) { + console.error("Could not copy text: ", err); + }); +} \ No newline at end of file diff --git a/src/main/resources/templates/filePassword.html b/src/main/resources/templates/filePassword.html index 6134ef9..b19b7c3 100644 --- a/src/main/resources/templates/filePassword.html +++ b/src/main/resources/templates/filePassword.html @@ -3,12 +3,30 @@