扩展上传文件接口
This commit is contained in:
parent
94cd46e73d
commit
f0a0f40515
@ -1,8 +1,10 @@
|
||||
package cn.axzo.oss.client.controller;
|
||||
|
||||
import cn.axzo.oss.client.vo.FileInformationVo;
|
||||
import cn.axzo.oss.client.vo.WebFileUploadVo;
|
||||
import cn.axzo.oss.common.utils.BeanConvertUtil;
|
||||
import cn.axzo.oss.manager.api.dto.request.ServerFileUploadDto;
|
||||
import cn.axzo.oss.manager.api.dto.response.FileInformationResponse;
|
||||
import cn.axzo.oss.manager.api.dto.response.ServerFileUploadResponse;
|
||||
import cn.axzo.oss.service.api.FileService;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
@ -42,4 +44,21 @@ public class WebFileController {
|
||||
return CommonResponse.success(result);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/v2/file")
|
||||
@CrossOrigin
|
||||
@SneakyThrows
|
||||
public CommonResponse<FileInformationVo> uploadV2(@Valid @RequestParam String appCode,
|
||||
@Valid @RequestParam String bizScene,
|
||||
@Valid @RequestParam MultipartFile file) {
|
||||
ServerFileUploadDto fileUploadDto = ServerFileUploadDto.builder()
|
||||
.appCode(appCode)
|
||||
.bizScene(bizScene)
|
||||
.fileName(file.getOriginalFilename())
|
||||
.fileContent(file.getBytes())
|
||||
.build();
|
||||
FileInformationResponse response = fileService.uploadV2(fileUploadDto);
|
||||
FileInformationVo result = BeanConvertUtil.copyBean(response, FileInformationVo.class);
|
||||
return CommonResponse.success(result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package cn.axzo.oss.client.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FileInformationVo {
|
||||
/**
|
||||
* 文件 URL
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
private String fileName;
|
||||
/**
|
||||
* 文件大小
|
||||
*/
|
||||
private Long fileSize;
|
||||
|
||||
/**
|
||||
* URL MD5
|
||||
*/
|
||||
private String urlMd5;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user