* ADD thumbnail to database * ADD thumbnail generation and retrieval functionality * ADD thumbnail availability check in VideoCard component * ADD ClipDTO to reduce exposed internals * REFactor move APIResponse and VideoMetadata to dto package * REMOVE unused props from VideoCard * ADD isThumbnailAvailable function
32 lines
1.1 KiB
Java
32 lines
1.1 KiB
Java
package com.ddf.vodsystem.controllers;
|
|
|
|
import com.ddf.vodsystem.dto.APIResponse;
|
|
import com.ddf.vodsystem.services.UploadService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
@RestController
|
|
@RequestMapping("api/v1/upload")
|
|
public class UploadController {
|
|
|
|
private final UploadService uploadService;
|
|
|
|
@Autowired
|
|
public UploadController(UploadService uploadService) {
|
|
this.uploadService = uploadService;
|
|
}
|
|
|
|
@PostMapping()
|
|
public ResponseEntity<APIResponse<Object>> uploadVideo(@RequestParam("file") MultipartFile file) {
|
|
if (file == null || file.isEmpty()) {
|
|
throw new IllegalArgumentException("Invalid file");
|
|
}
|
|
|
|
String uuid = uploadService.upload(file);
|
|
APIResponse<Object> response = new APIResponse<>("success", "File uploaded successfully", java.util.Collections.singletonMap("uuid", uuid));
|
|
return new ResponseEntity<>(response, HttpStatus.OK);
|
|
}
|
|
} |