📖 CRM:code review 前端直接上传

This commit is contained in:
YunaiV
2024-02-17 20:35:48 +08:00
parent b2782e1d9a
commit 63f322cb17
8 changed files with 34 additions and 30 deletions

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.framework.file.core.client;
import cn.iocoder.yudao.framework.file.core.client.s3.FilePresignedUrlBO;
import cn.iocoder.yudao.framework.file.core.client.s3.FilePresignedUrlRespDTO;
/**
* 文件客户端
@ -45,10 +45,10 @@ public interface FileClient {
/**
* 获得文件预签名地址
*
* @param fileName 文件名称
* @param path 相对路径
* @return 文件预签名地址
*/
default FilePresignedUrlBO getPresignedObjectUrl(String fileName) throws Exception {
default FilePresignedUrlRespDTO getPresignedObjectUrl(String path) throws Exception {
throw new UnsupportedOperationException("不支持的操作");
}

View File

@ -5,17 +5,19 @@ import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 文件预签名地址 BO
* 文件预签名地址 Response DTO
*
* @author owen
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Data
public class FilePresignedUrlBO {
public class FilePresignedUrlRespDTO {
/**
* 文件上传 URL用于上传
*
* 例如说
*/
private String uploadUrl;

View File

@ -120,18 +120,15 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
}
@Override
public FilePresignedUrlBO getPresignedObjectUrl(String fileName) throws Exception {
public FilePresignedUrlRespDTO getPresignedObjectUrl(String path) throws Exception {
String uploadUrl = client.getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder()
.method(Method.PUT)
.bucket(config.getBucket())
.object(fileName)
/**
* 过期时间秒数取值范围1秒 ~ 7天
* {@link GetPresignedObjectUrlArgs.Builder#validateExpiry(int)}
*/
.expiry(10, TimeUnit.MINUTES)
.object(path)
.expiry(10, TimeUnit.MINUTES) // 过期时间秒数取值范围1 秒 ~ 7 天
.build()
);
return new FilePresignedUrlBO(uploadUrl, config.getDomain() + "/" + fileName);
return new FilePresignedUrlRespDTO(uploadUrl, config.getDomain() + "/" + path);
}
}