mirror of
https://github.com/BgaSol/sol-cloud
synced 2026-05-05 23:58:33 +00:00
test: Add streamFile
This commit is contained in:
parent
3ef4a0a395
commit
5aa47b663b
1 changed files with 13 additions and 0 deletions
|
|
@ -99,4 +99,17 @@ public class FileController extends BaseController<
|
|||
.contentType(MediaType.valueOf(file.getType()))
|
||||
.body(new InputStreamResource(ossService.readFileStream(file.getBucket(), file.getId(), file.getName())));
|
||||
}
|
||||
|
||||
@GetMapping("/stream/{id}")
|
||||
@Operation(summary = "在线播放文件", operationId = "streamFile")
|
||||
@SaCheckPermission("file:stream")
|
||||
public ResponseEntity<InputStreamResource> stream(@PathVariable("id") String id) {
|
||||
FileEntity file = fileService.findById(id);
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.valueOf(file.getType())) // video/mp4
|
||||
.header(HttpHeaders.CONTENT_LENGTH, String.valueOf(file.getSize()))
|
||||
.body(new InputStreamResource(
|
||||
ossService.readFileStream(file.getBucket(), file.getId(), file.getName())
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue