【同步】BOOT 和 CLOUD 的功能
parent
8e45cf5787
commit
816e1fbf9b
|
|
@ -105,8 +105,8 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
|
||||||
@Override
|
@Override
|
||||||
public String presignPutUrl(String path) {
|
public String presignPutUrl(String path) {
|
||||||
return presigner.presignPutObject(PutObjectPresignRequest.builder()
|
return presigner.presignPutObject(PutObjectPresignRequest.builder()
|
||||||
.signatureDuration(EXPIRATION_DEFAULT)
|
.signatureDuration(EXPIRATION_DEFAULT)
|
||||||
.putObjectRequest(b -> b.bucket(config.getBucket()).key(path)).build())
|
.putObjectRequest(b -> b.bucket(config.getBucket()).key(path)).build())
|
||||||
.url().toString();
|
.url().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -126,15 +126,10 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
|
||||||
String finalPath = path;
|
String finalPath = path;
|
||||||
Duration expiration = expirationSeconds != null ? Duration.ofSeconds(expirationSeconds) : EXPIRATION_DEFAULT;
|
Duration expiration = expirationSeconds != null ? Duration.ofSeconds(expirationSeconds) : EXPIRATION_DEFAULT;
|
||||||
URL signedUrl = presigner.presignGetObject(GetObjectPresignRequest.builder()
|
URL signedUrl = presigner.presignGetObject(GetObjectPresignRequest.builder()
|
||||||
.signatureDuration(expiration)
|
.signatureDuration(expiration)
|
||||||
.getObjectRequest(b -> b.bucket(config.getBucket()).key(finalPath)).build())
|
.getObjectRequest(b -> b.bucket(config.getBucket()).key(finalPath)).build())
|
||||||
.url();
|
.url();
|
||||||
// 特殊:适配未使用 domain 返回的情况!!!
|
return signedUrl.toString();
|
||||||
String signedUrlStr = signedUrl.toString();
|
|
||||||
if (!signedUrlStr.startsWith(config.getDomain())) {
|
|
||||||
signedUrlStr = signedUrlStr.replaceFirst(signedUrl.getProtocol() + "://" + signedUrl.getHost(), config.getDomain());
|
|
||||||
}
|
|
||||||
return signedUrlStr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue