You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.9 KiB
89 lines
2.9 KiB
2 years ago
|
package com.zilber.boot.file.controller;
|
||
|
|
||
|
import com.aliyun.oss.model.*;
|
||
|
import com.zilber.boot.file.entity.*;
|
||
|
import com.zilber.boot.file.service.UploadUtils;
|
||
|
import io.swagger.annotations.Api;
|
||
|
import io.swagger.annotations.ApiOperation;
|
||
|
import lombok.RequiredArgsConstructor;
|
||
|
import org.springframework.validation.annotation.Validated;
|
||
|
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.RestController;
|
||
|
import org.springframework.web.multipart.MultipartFile;
|
||
|
import reactor.util.annotation.Nullable;
|
||
|
|
||
|
import java.io.IOException;
|
||
|
import java.util.Map;
|
||
|
|
||
|
@Validated
|
||
|
@RestController
|
||
|
@RequiredArgsConstructor
|
||
|
@RequestMapping("/file")
|
||
|
@Api(tags = "基本功能管理")
|
||
|
public class FileUploadController {
|
||
|
|
||
|
private final UploadUtils uploadUtils;
|
||
|
|
||
|
@ApiOperation("文件上传服务器")
|
||
|
@PostMapping("/upload")
|
||
|
public Map<String, String> uploadFile(MultipartFile file) {
|
||
|
return uploadUtils.upload(file);
|
||
|
}
|
||
|
|
||
|
@ApiOperation("分片上传服务器")
|
||
|
@PostMapping("/slice")
|
||
|
public ETag sliceUploads(FileUploadsRequestDTO param) {
|
||
|
return uploadUtils.sliceUploads(param);
|
||
|
}
|
||
|
|
||
|
@ApiOperation("分片上传检测-服务器")
|
||
|
@PostMapping("/check")
|
||
|
public PartList fileCheck(String fileMd5, String UUID) throws IOException {
|
||
|
return uploadUtils.fileCheck(fileMd5, UUID);
|
||
|
}
|
||
|
|
||
|
@ApiOperation("分片上传合成-服务器")
|
||
|
@PostMapping("/compose")
|
||
|
public Complete compose(@RequestBody ComposeDTO dto) {
|
||
|
return uploadUtils.compose(dto.getUuid(), dto.getType(), dto.getFileMd5());
|
||
|
}
|
||
|
|
||
|
@ApiOperation("文件上传oss服务器")
|
||
|
@PostMapping("/oss/upload")
|
||
|
public Map<String, String> uploadFileToOss(MultipartFile file) {
|
||
|
return uploadUtils.upload(file, null);
|
||
|
}
|
||
|
|
||
|
@ApiOperation("分片上传初始化-oss服务器")
|
||
|
@PostMapping("/oss/initiate")
|
||
|
public OssPartUpload initiate(String fileName) {
|
||
|
return uploadUtils.InitiateMultipartUpload(fileName, null, null);
|
||
|
}
|
||
|
|
||
|
@ApiOperation("分片上传-oss服务器")
|
||
|
@PostMapping("/oss/slice")
|
||
|
public PartETag sliceUploads(OssPartUpload upload) {
|
||
|
return uploadUtils.uploadPart(upload);
|
||
|
}
|
||
|
|
||
|
@ApiOperation("分片上传检测-oss服务器")
|
||
|
@PostMapping("/oss/check")
|
||
|
public PartListing PartListing(OssListParts parts) {
|
||
|
return uploadUtils.list(parts);
|
||
|
}
|
||
|
|
||
|
@ApiOperation("分片上传合成-oss服务器")
|
||
|
@PostMapping("/oss/compose")
|
||
|
public CompleteMultipartUploadResult compose(@RequestBody OssComplete complete) {
|
||
|
return uploadUtils.completeUpload(complete);
|
||
|
}
|
||
|
|
||
|
@ApiOperation("分片上传取消-oss服务器")
|
||
|
@PostMapping("/oss/abort")
|
||
|
public void abort(OssCancel cancel) {
|
||
|
uploadUtils.abortUpload(cancel);
|
||
|
}
|
||
|
|
||
|
}
|