| | |
| | | package com.tcm.training.admin.upload; |
| | | |
| | | import com.tcm.training.admin.common.ApiResponse; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | | |
| | | import javax.validation.Valid; |
| | | |
| | | @Validated |
| | | @RestController |
| | | @RequestMapping({"/api/v1", "/api"}) |
| | | public class UploadController { |
| | |
| | | |
| | | private final ObsUploadService obsUploadService; |
| | | private final UploadProgressService uploadProgressService; |
| | | private final RemoteVideoDurationService remoteVideoDurationService; |
| | | |
| | | public UploadController(ObsUploadService obsUploadService, UploadProgressService uploadProgressService) { |
| | | public UploadController(ObsUploadService obsUploadService, |
| | | UploadProgressService uploadProgressService, |
| | | RemoteVideoDurationService remoteVideoDurationService) { |
| | | this.obsUploadService = obsUploadService; |
| | | this.uploadProgressService = uploadProgressService; |
| | | this.remoteVideoDurationService = remoteVideoDurationService; |
| | | } |
| | | |
| | | /** |
| | |
| | | return ApiResponse.ok(storeFile(file, VIDEO_MAX_SIZE, ALLOWED_VIDEO_TYPES, "仅支持 MP4、MOV、AVI、MKV、WebM 格式", "video", uploadTaskId)); |
| | | } |
| | | |
| | | /** |
| | | * 远程视频时长识别。 |
| | | */ |
| | | @PostMapping("/upload/video/duration") |
| | | public ApiResponse<VideoDurationDetectVO> detectVideoDuration( |
| | | @Valid @RequestBody VideoDurationDetectRequest request) { |
| | | return ApiResponse.ok(remoteVideoDurationService.detectDuration(request.getVideoUrl())); |
| | | } |
| | | |
| | | @PostMapping("/upload/app-package") |
| | | public ApiResponse<UploadResult> uploadAppPackage( |
| | | @RequestParam("file") MultipartFile file, |