diff --git a/frontend/src/app/upload/upload.component.ts b/frontend/src/app/upload/upload.component.ts
index fdc2c96..8251840 100644
--- a/frontend/src/app/upload/upload.component.ts
+++ b/frontend/src/app/upload/upload.component.ts
@@ -147,7 +147,7 @@ export class UploadComponent {
axios({
method: 'post',
- url: 'http://localhost/api/v1/upload-speed-test',
+ url: this.developmentStore.getBaseUrl() + 'api/v1/upload-speed-test',
data: uint8View,
headers: {
'Content-Type': 'application/octet-stream',
diff --git a/frontend/src/assets/funfacts.ts b/frontend/src/assets/funfacts.ts
new file mode 100644
index 0000000..7edf729
--- /dev/null
+++ b/frontend/src/assets/funfacts.ts
@@ -0,0 +1,24 @@
+
+let funfacts = [
+ "Honey never spoils. Archaeologists have found pots of honey in ancient Egyptian tombs that are over 3,000 years old and still edible.",
+ "Octopuses have three hearts and blue blood.",
+ "Bananas are berries, but strawberries are not.",
+ "The shortest war in history was between Britain and Zanzibar on August 27, 1896. Zanzibar surrendered after 38 minutes.",
+ "A day on Venus is longer than a year on Venus.",
+ "The Eiffel Tower can be 15 cm taller during the summer when the iron heats up and expands.",
+ "Cows have best friends and can become stressed if they are separated.",
+ "A group of flamingos is called a flamboyance.",
+ "The unicorn is the national animal of Scotland.",
+ "More people are killed each year by cows than by sharks.",
+ "The total weight of all the ants on Earth is about the same as the weight of all the humans on Earth.",
+ "Wombat poop is cube-shaped.",
+ "The inventor of the frisbee was turned into a frisbee after he died.",
+ "There are more possible iterations of a game of chess than there are atoms in the known universe.",
+ "The heart of a blue whale is so large that a human can swim through the arteries.",
+ "Vending machines kill 4 times as many people as sharks per year.",
+ "Butterflies taste with their feet.",
+ "In Switzerland, it is illegal to own just one guinea pig because they are prone to loneliness.",
+ "Snails can sleep for up to three years.",
+ "The old Twitter bird actually had a name - Larry."
+];
+export default funfacts;
diff --git a/frontend/src/assets/poop-solid.svg b/frontend/src/assets/poop-solid.svg
new file mode 100644
index 0000000..e38eabb
--- /dev/null
+++ b/frontend/src/assets/poop-solid.svg
@@ -0,0 +1 @@
+
diff --git a/src/main/java/de/w665/sharepulse/db/repo/FileUploadRepository.java b/src/main/java/de/w665/sharepulse/db/repo/FileUploadRepository.java
index e82c99a..24278ae 100644
--- a/src/main/java/de/w665/sharepulse/db/repo/FileUploadRepository.java
+++ b/src/main/java/de/w665/sharepulse/db/repo/FileUploadRepository.java
@@ -14,6 +14,8 @@ import org.springframework.stereotype.Repository;
import java.lang.reflect.Type;
import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Optional;
@Repository
@RequiredArgsConstructor
@@ -44,11 +46,17 @@ public class FileUploadRepository {
r.db("sharepulse").table("file_uploads").insert(map).run(connection);
}
- public FileUpload retrieveFileUploadByFileId(String fileId) {
- return r.db("sharepulse").table("file_uploads")
- .filter(r.hashMap("fileId", fileId))
- .run(connection, FileUpload.class)
- .next();
+ public Optional
retrieveFileUploadByFileId(String fileId) {
+ try {
+ FileUpload fileUpload = r.db("sharepulse").table("file_uploads")
+ .filter(r.hashMap("fileId", fileId))
+ .run(connection, FileUpload.class)
+ .next();
+ return Optional.ofNullable(fileUpload);
+ } catch (NoSuchElementException e) {
+ return Optional.empty();
+ }
+
}
public void updateFileUpload(FileUpload updatedFileUpload) {
diff --git a/src/main/java/de/w665/sharepulse/rest/TestRestResource.java b/src/main/java/de/w665/sharepulse/rest/TestRestResource.java
index ce94c50..790c454 100644
--- a/src/main/java/de/w665/sharepulse/rest/TestRestResource.java
+++ b/src/main/java/de/w665/sharepulse/rest/TestRestResource.java
@@ -28,9 +28,9 @@ public class TestRestResource extends ApiRestController {
}
@GetMapping("test")
- public String test(@RequestParam String id) {
- FileUpload fileUpload = fileUploadRepository.retrieveFileUploadByFileId(id);
- return fileUpload != null ? fileUpload.toString() : "FileUpload not found for id: " + id;
+ public FileUpload test(@RequestParam String id) {
+ FileUpload fileUpload = fileUploadRepository.retrieveFileUploadByFileId(id).orElse(null);
+ return fileUpload;
}
@GetMapping("test/download")
diff --git a/src/main/java/de/w665/sharepulse/rest/mappings/Download.java b/src/main/java/de/w665/sharepulse/rest/mappings/Download.java
index b534780..494e011 100644
--- a/src/main/java/de/w665/sharepulse/rest/mappings/Download.java
+++ b/src/main/java/de/w665/sharepulse/rest/mappings/Download.java
@@ -22,6 +22,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import java.util.Optional;
@Slf4j
@RestController
@@ -41,7 +42,11 @@ public class Download extends ApiRestController {
@RequestParam(value = "password", required = false) String password) throws IOException {
- FileUpload fileUpload = fileService.getFileUploadByFileId(fileId);
+ Optional optionalFileUpload = fileService.getFileUploadByFileId(fileId);
+ FileUpload fileUpload = optionalFileUpload.orElse(null);
+ if(optionalFileUpload.isEmpty()) {
+ return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+ }
try {
fileSecurityService.verifyDownloadPermission(fileUpload, password);
@@ -63,6 +68,7 @@ public class Download extends ApiRestController {
headers.add(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, must-revalidate");
headers.add(HttpHeaders.PRAGMA, "no-cache");
headers.add(HttpHeaders.EXPIRES, "0");
+ headers.add(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "Content-Disposition");
return ResponseEntity.ok()
.headers(headers)
@@ -73,12 +79,19 @@ public class Download extends ApiRestController {
@GetMapping("/download-info")
public ResponseEntity