mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-13 10:35:07 +08:00
基础设施:前端直连上传,优先使用自定义域名
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
package cn.iocoder.yudao.framework.file.core.client;
|
||||
|
||||
import cn.iocoder.yudao.framework.file.core.client.s3.FilePresignedUrlBO;
|
||||
|
||||
/**
|
||||
* 文件客户端
|
||||
*
|
||||
@ -46,7 +48,7 @@ public interface FileClient {
|
||||
* @param fileName 文件名称
|
||||
* @return 文件预签名地址
|
||||
*/
|
||||
default String getPresignedObjectUrl(String fileName) throws Exception {
|
||||
default FilePresignedUrlBO getPresignedObjectUrl(String fileName) throws Exception {
|
||||
throw new UnsupportedOperationException("不支持的操作");
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.framework.file.core.client.s3;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 文件预签名地址 BO
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class FilePresignedUrlBO {
|
||||
|
||||
/**
|
||||
* 文件上传 URL(用于上传)
|
||||
*/
|
||||
private String uploadUrl;
|
||||
|
||||
/**
|
||||
* 文件 URL(用于读取、下载等)
|
||||
*/
|
||||
private String url;
|
||||
|
||||
}
|
@ -120,8 +120,8 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPresignedObjectUrl(String fileName) throws Exception {
|
||||
return client.getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder()
|
||||
public FilePresignedUrlBO getPresignedObjectUrl(String fileName) throws Exception {
|
||||
String uploadUrl = client.getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder()
|
||||
.method(Method.PUT)
|
||||
.bucket(config.getBucket())
|
||||
.object(fileName)
|
||||
@ -132,5 +132,6 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
|
||||
.expiry(10, TimeUnit.MINUTES)
|
||||
.build()
|
||||
);
|
||||
return new FilePresignedUrlBO(uploadUrl, config.getDomain() + "/" + fileName);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user