fix 修改防止多次加签的问题

pull/84/head
duandazhi 4 years ago
parent c51ecdd680
commit 80db2e2b9e

@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

@ -42,7 +42,7 @@ import java.util.concurrent.TimeUnit;
* @date 2019/8/6 19:02
* //@see AliyunMsgUtil
*/
//@Primary
@Primary
@Service()
public class AliyunOssDsfServiceImpl implements IDfsService {
private static final Logger log = LoggerFactory.getLogger(AliyunOssDsfServiceImpl.class);
@ -519,13 +519,17 @@ public class AliyunOssDsfServiceImpl implements IDfsService {
/**
* @param fileUrl https://react-yuebaoxiao-pro.oss-cn-shanghai.aliyuncs.com/dev/upload/default/20210722-03f07351-ae82-410a-a43c-0797a82f07b4.jpeg
* @return
* @return http://react-yuebaoxiao-pro.oss-cn-shanghai.aliyuncs.com/dev/upload/default/20210809-1f545f8e-560c-442d-bd94-95656c77d879.png?Expires=1628528557&OSSAccessKeyId=LTAI4GDQSbwgmbsRxxbDXnKT&Signature=6pPP50doxwCC3cMzHFzgdkf95YQ%3D
*/
@Override
public String presignedUrl(String fileUrl) {
if (aliyunOssConfig.getExpiryDuration() == -1) {
return fileUrl;
}
String signKey = "?Expires=";
if (fileUrl.contains(signKey)) {
return fileUrl;
}
String objectKey = this.getStorePath(fileUrl);
return this.getStsURL(objectKey);
}

@ -88,6 +88,10 @@ public class FastDfsServiceImpl implements IDfsService
if (StringUtils.isBlank(fastDfsConfig.getTokenSecretKey())) {
throw new CustomException("防盗链生成token的密钥为空请检查tokenSecretKey");
}
String signKey = "?token=";
if (fileUrl.contains(signKey)) {
return fileUrl;
}
String tokenSecretKey = fastDfsConfig.getTokenSecretKey();
StorePath storePath = StorePath.parseFromUrl(fileUrl);

@ -142,12 +142,17 @@ public class MinioDfsServiceImpl implements IDfsService
* http://docs.minio.org.cn/docs/master/minio-sts-quickstart-guide
* minio SDKS Java Client API http://docs.minio.org.cn/docs/master/java-client-api-reference
* Presigned presignedGetObject
* https://xxxx.xxx.gov.cn/file/2021/08/06/cd9dfbaa-8563-423a-bc3d-d0b15e781931.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=D99KGE6ZTQXSATTJWU24%2F20210809%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210809T075702Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=198c76edc57998f4dde72124952b43f0066c762356e485dd44d21df9cc7dad78
*/
@Override
public String presignedUrl(String fileUrl) {
if (minioConfig.getExpiryDuration() == -1) {
return fileUrl;
}
String signKey = "?X-Amz-Algorithm=";
if (fileUrl.contains(signKey)) {
return fileUrl;
}
String objectName = this.getStorePath(fileUrl);
GetPresignedObjectUrlArgs args = GetPresignedObjectUrlArgs.builder().
bucket(minioConfig.getBucketName()).

@ -127,6 +127,10 @@ public class QiniuDfsServiceImpl implements IDfsService {
if (qiniuKodoConfig.getExpiryDuration() == -1) {
return fileUrl;
}
String signKey = "?e=";
if (fileUrl.contains(signKey)) {
return fileUrl;
}
//...其他参数参考类注释
String accessKey = qiniuKodoConfig.getAccessKey();
String secretKey = qiniuKodoConfig.getSecretKey();

@ -23,7 +23,7 @@ import java.util.List;
* @author yabo
* @see TencentCosConfig
*/
@Primary
//@Primary
@Service()
public class TencentCosServiceImpl implements IDfsService {
private final COSClient cosClient;
@ -168,6 +168,10 @@ public class TencentCosServiceImpl implements IDfsService {
if (config.getExpiryDuration() == -1) {
return fileUrl;
}
String signKey = "?sign=";
if (fileUrl.contains(signKey)) {
return fileUrl;
}
// 存储桶的命名格式为 BucketName-APPID此处填写的存储桶名称必须为此格式
String bucketName = config.getBucketName();
if (StringUtils.isBlank(config.getBucketName())) {

Loading…
Cancel
Save