diff --git a/compose.yaml b/compose.yaml deleted file mode 100644 index 0baad47..0000000 --- a/compose.yaml +++ /dev/null @@ -1 +0,0 @@ -services: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..6a2604d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3.8' + +services: + postgres: + image: postgres:15 + container_name: my_postgres + environment: + POSTGRES_USER: myuser + POSTGRES_PASSWORD: mypassword + POSTGRES_DB: mydb + ports: + - "5432:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + +volumes: + postgres_data: \ No newline at end of file diff --git a/pom.xml b/pom.xml index 4fc6cf6..f1e30c5 100644 --- a/pom.xml +++ b/pom.xml @@ -42,12 +42,6 @@ runtime true - - org.springframework.boot - spring-boot-docker-compose - runtime - true - org.projectlombok lombok @@ -58,6 +52,20 @@ spring-boot-starter-test test + + org.postgresql + postgresql + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-docker-compose + runtime + true + @@ -89,6 +97,7 @@ org.springframework.boot spring-boot-maven-plugin + --enable-native-access=ALL-UNNAMED org.projectlombok diff --git a/src/main/java/com/ddf/vodsystem/controllers/vodController.java b/src/main/java/com/ddf/vodsystem/controllers/vodController.java new file mode 100644 index 0000000..cb22db2 --- /dev/null +++ b/src/main/java/com/ddf/vodsystem/controllers/vodController.java @@ -0,0 +1,40 @@ +package com.ddf.vodsystem.controllers; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; + +@RestController +public class vodController { + + private static final String UPLOAD_DIR = "videos/"; + + @PostMapping("/upload") + public ResponseEntity uploadVideo(@RequestParam("file") MultipartFile file) { + try { + File uploadDir = new File(UPLOAD_DIR); + + if (!uploadDir.exists()) { + uploadDir.mkdirs(); + } + + Path filePath = Paths.get(UPLOAD_DIR, file.getOriginalFilename()); + Files.copy(file.getInputStream(), filePath, StandardCopyOption.REPLACE_EXISTING); + + return ResponseEntity.ok("Uploaded: " + file.getOriginalFilename()); + } catch (IOException e) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body("Upload failed: " + e.getMessage()); + } + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c4e1ab6..b3a76e9 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,2 +1,15 @@ vaadin.launch-browser=true spring.application.name=vodSystem + +# VODs +spring.servlet.multipart.max-file-size=2GB +spring.servlet.multipart.max-request-size=2GB + +# Database +spring.datasource.url=jdbc:postgresql://localhost:5432/mydb +spring.datasource.username=myuser +spring.datasource.password=mypassword +spring.datasource.driver-class-name=org.postgresql.Driver +spring.jpa.hibernate.ddl-auto=update +spring.jpa.show-sql=true +spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect \ No newline at end of file