Merge branch 'hotfix/download_sign_url_change_max_size_1010' into 'master'
Hotfix/download sign url change max size 1010 See merge request universal/infrastructure/backend/oss!157
This commit is contained in:
commit
9bfdd3afa8
@ -62,7 +62,8 @@ public enum CodeEnum implements EnumBase<Integer> {
|
||||
FILE_APP_IS_EMPTY(505, "app is empty"),
|
||||
BUCKET_TYPE_IS_EMPTY(506, "bucketType is empty"),
|
||||
GET_OBJECT_META_FAIL(507, "获取元文件失败"),
|
||||
URL_BUCKET_NAME_KEY_ALL_EMPTY(508, "url-bucketName-key同时为空")
|
||||
URL_BUCKET_NAME_KEY_ALL_EMPTY(508, "url-bucketName-key同时为空"),
|
||||
SIGN_URL_DOWNLOAD_FILEKEYS_EXCEEDS_MAXSIZE(509, "fileKeys exceeds the maximum size"),
|
||||
;
|
||||
|
||||
private final Integer code;
|
||||
|
||||
@ -6,7 +6,6 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -24,7 +23,6 @@ public class ApiSignUrlDownloadRequest {
|
||||
* 文件uuid
|
||||
*/
|
||||
@NotEmpty(message = "fileKeys not empty")
|
||||
@Size(min = 1, max = 1000, message = "超过指定范围1-1000")
|
||||
private List<String> fileKeys;
|
||||
|
||||
/**
|
||||
|
||||
@ -62,6 +62,7 @@ import cn.azxo.framework.common.model.CommonResponse;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -141,6 +142,9 @@ public class FileServiceImpl implements FileService {
|
||||
@Value("${sign.url.download.expire.second:2000}")
|
||||
private Long SIGN_URL_DOWNLOAD_EXPIRE_SECOND;
|
||||
|
||||
@Value("${sign.url.download.maxsize:10000}")
|
||||
private Integer SIGN_URL_DOWNLOAD_MAXSIZE;
|
||||
|
||||
@Autowired
|
||||
private WithFileFactory withFileFactory;
|
||||
|
||||
@ -859,6 +863,9 @@ public class FileServiceImpl implements FileService {
|
||||
*/
|
||||
@Override
|
||||
public List<SignUrlDownloadResponse> signUrlDownload(SignUrlDownloadDto dto) {
|
||||
//临时授权下载校验
|
||||
this.checkSignUrlDownload(dto);
|
||||
|
||||
log.info("signUrl download dto = {}", JsonUtil.obj2Str(dto));
|
||||
Long start = System.currentTimeMillis();
|
||||
//是否代文件名称
|
||||
@ -884,6 +891,18 @@ public class FileServiceImpl implements FileService {
|
||||
return httpUrlResList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 临时授权下载校验
|
||||
*/
|
||||
private void checkSignUrlDownload(SignUrlDownloadDto dto) {
|
||||
if (dto.getFileKeys().size() > SIGN_URL_DOWNLOAD_MAXSIZE) {
|
||||
throw new BizException(CodeEnum.SIGN_URL_DOWNLOAD_FILEKEYS_EXCEEDS_MAXSIZE, "signUrlDownload fileKeys 大小超过" + SIGN_URL_DOWNLOAD_MAXSIZE);
|
||||
}
|
||||
if (dto.getFileKeys().size() > 1000) {
|
||||
log.info("fileservice#signUrlDownload,fileKeys-size > 1000,dto:{},size:{}", JSON.toJSONString(dto), dto.getFileKeys().size());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建fileKey(非http的入参)的返回对象
|
||||
*/
|
||||
@ -1221,6 +1240,8 @@ public class FileServiceImpl implements FileService {
|
||||
*/
|
||||
@Override
|
||||
public List<SignUrlDownloadResponse> signUrlDownloadNoFile(SignUrlDownloadDto dto) {
|
||||
//临时授权下载校验
|
||||
this.checkSignUrlDownload(dto);
|
||||
|
||||
// 通过appcode获取文件渠道桶信息
|
||||
AppChannelBucket appChannelBucket = appChannelBucketManager.getByAppCode(dto.getAppCode(), null);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user