|
|
|
@ -69,6 +69,7 @@ public class FileServiceImpl implements FileService {
|
|
|
|
.setPath(p.getPath())
|
|
|
|
.setPath(p.getPath())
|
|
|
|
.setSaveFilename(p.getSaveFilename())
|
|
|
|
.setSaveFilename(p.getSaveFilename())
|
|
|
|
.putMetadata(isUpyunUss, "X-Upyun-Multi-Part-Size", String.valueOf(5 * 1024 * 1024))// 设置 Metadata,不需要可以不写
|
|
|
|
.putMetadata(isUpyunUss, "X-Upyun-Multi-Part-Size", String.valueOf(5 * 1024 * 1024))// 设置 Metadata,不需要可以不写
|
|
|
|
|
|
|
|
|
|
|
|
.init();
|
|
|
|
.init();
|
|
|
|
|
|
|
|
|
|
|
|
String uploadId = UUID.fastUUID().toString(true);
|
|
|
|
String uploadId = UUID.fastUUID().toString(true);
|
|
|
|
@ -85,6 +86,7 @@ public class FileServiceImpl implements FileService {
|
|
|
|
if (fileInfo == null) {
|
|
|
|
if (fileInfo == null) {
|
|
|
|
throw new RuntimeException("未初始化分片上传");
|
|
|
|
throw new RuntimeException("未初始化分片上传");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
service.uploadPart(fileInfo, partNumber, inputStream).upload();
|
|
|
|
service.uploadPart(fileInfo, partNumber, inputStream).upload();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -95,7 +97,9 @@ public class FileServiceImpl implements FileService {
|
|
|
|
if (fileInfo == null) {
|
|
|
|
if (fileInfo == null) {
|
|
|
|
throw new RuntimeException("未初始化分片上传");
|
|
|
|
throw new RuntimeException("未初始化分片上传");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
service.completeMultipartUpload(fileInfo).complete();
|
|
|
|
service.completeMultipartUpload(fileInfo).complete();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RedisUtils.deleteObject(CACHE_KEY_PREFIX + uploadId);
|
|
|
|
RedisUtils.deleteObject(CACHE_KEY_PREFIX + uploadId);
|
|
|
|
return fileInfo.getUrl();
|
|
|
|
return fileInfo.getUrl();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -131,7 +135,8 @@ public class FileServiceImpl implements FileService {
|
|
|
|
public Downloader download(String url) {
|
|
|
|
public Downloader download(String url) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
FileInfo fileInfo = getFileInfoByURL(url);
|
|
|
|
FileInfo fileInfo = getFileInfoByURL(url);
|
|
|
|
return service.download(fileInfo);
|
|
|
|
Param param = paramThreadLocal.get();
|
|
|
|
|
|
|
|
return service.download(fileInfo).setHashCalculatorMd5(param.isMd5()).setHashCalculatorSha256(param.isSha256());
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
paramThreadLocal.remove();
|
|
|
|
paramThreadLocal.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -147,7 +152,7 @@ public class FileServiceImpl implements FileService {
|
|
|
|
|
|
|
|
|
|
|
|
if (fileStorage.isSupportPresignedUrl()) {
|
|
|
|
if (fileStorage.isSupportPresignedUrl()) {
|
|
|
|
url = generatePresignedUrlInner(url, null, fileInfo, fileStorage);
|
|
|
|
url = generatePresignedUrlInner(url, null, fileInfo, fileStorage);
|
|
|
|
log.debug("跳转:"+url);
|
|
|
|
log.debug("跳转:" + url);
|
|
|
|
response.reset();
|
|
|
|
response.reset();
|
|
|
|
response.setStatus(HttpServletResponse.SC_FOUND);
|
|
|
|
response.setStatus(HttpServletResponse.SC_FOUND);
|
|
|
|
response.setHeader("Location", url);
|
|
|
|
response.setHeader("Location", url);
|
|
|
|
@ -238,7 +243,11 @@ public class FileServiceImpl implements FileService {
|
|
|
|
UploadPretreatment p = service.of(in);
|
|
|
|
UploadPretreatment p = service.of(in);
|
|
|
|
Param param = paramThreadLocal.get();
|
|
|
|
Param param = paramThreadLocal.get();
|
|
|
|
initUploadPretreatment(p, param);
|
|
|
|
initUploadPretreatment(p, param);
|
|
|
|
return p.upload().getUrl();
|
|
|
|
FileInfo fileInfo = p.upload();
|
|
|
|
|
|
|
|
if (param.isSha256() || param.isMd5()) {
|
|
|
|
|
|
|
|
hashInfoThreadLocal.set(fileInfo.getHashInfo());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return fileInfo.getUrl();
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
paramThreadLocal.remove();
|
|
|
|
paramThreadLocal.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -257,7 +266,11 @@ public class FileServiceImpl implements FileService {
|
|
|
|
param.setFilename(FileService.DEFAULT_IMAGE_FILENAME);
|
|
|
|
param.setFilename(FileService.DEFAULT_IMAGE_FILENAME);
|
|
|
|
UploadPretreatment p = service.of(formatImage(image, param.getMaxWidth(), param.getMaxHeight(), param.getWatermark()));
|
|
|
|
UploadPretreatment p = service.of(formatImage(image, param.getMaxWidth(), param.getMaxHeight(), param.getWatermark()));
|
|
|
|
initUploadPretreatment(p, param);
|
|
|
|
initUploadPretreatment(p, param);
|
|
|
|
String url = p.upload().getUrl();
|
|
|
|
FileInfo fileInfo = p.upload();
|
|
|
|
|
|
|
|
if (param.isSha256() || param.isMd5()) {
|
|
|
|
|
|
|
|
hashInfoThreadLocal.set(fileInfo.getHashInfo());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String url = fileInfo.getUrl();
|
|
|
|
if (param.getThHeight() > 0 && param.getThWidth() > 0) {
|
|
|
|
if (param.getThHeight() > 0 && param.getThWidth() > 0) {
|
|
|
|
UploadPretreatment p1 = service.of(formatImage(image, param.getThWidth(), param.getThHeight(), null));
|
|
|
|
UploadPretreatment p1 = service.of(formatImage(image, param.getThWidth(), param.getThHeight(), null));
|
|
|
|
String platform = param.getPlatform();
|
|
|
|
String platform = param.getPlatform();
|
|
|
|
@ -346,6 +359,14 @@ public class FileServiceImpl implements FileService {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
p = p.setPlatform(service.getFileStorage().getPlatform());
|
|
|
|
p = p.setPlatform(service.getFileStorage().getPlatform());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (param.isMd5()) {
|
|
|
|
|
|
|
|
p = p.setHashCalculatorMd5();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (param.isSha256()) {
|
|
|
|
|
|
|
|
p = p.setHashCalculatorSha256();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String uri = param.getUri();
|
|
|
|
String uri = param.getUri();
|
|
|
|
if (StrUtil.isBlank(uri)) {
|
|
|
|
if (StrUtil.isBlank(uri)) {
|
|
|
|
String rule = param.getRule();
|
|
|
|
String rule = param.getRule();
|
|
|
|
|