* See full code here : https://github.com/davinkevin/Podcast-Server/blob/d927d9b8cb9ea1268af74316cd20b7192ca92da7/src/main/java/lan/dk/podcastserver/utils/multipart/MultipartFileSender.java
* Updated by limecoder on 23/04/19
*/
@Slf4j
@Component(value = "multipartFileSender")
@RequiredArgsConstructor
@Scope("prototype")
public class MultipartFileSender {
private static final int DEFAULT_BUFFER_SIZE = 20480; // ..bytes = 20KB.
private static final long DEFAULT_EXPIRE_TIME = 604800000L; // ..ms = 1 week.
private static final String MULTIPART_BOUNDARY = "MULTIPART_BYTERANGES";
private static final String PATTERN = "^bytes=\\d*-\\d*(/\\d*)?(,\\d*-\\d*(/\\d*)?)*$";
private final HttpServletRequest request;
private final HttpServletResponse response;
private final VideoMapper videoMapper;
private final MinioService minioService;
public void sent(Long videoId) throws Exception {
if (response == null || request == null) {
log.warn("http-request/http-response 注入失败");
return;
}
Video video = videoMapper.selectById(videoId);
/*
* 处理视频不存在的情况
* */
if (video == null) {
log.error("videoId doesn't exist at database : {}", videoId);