!144 优化构建临时文件

Merge pull request !144 from AprilWind/feat/dev-aws2x
2.X
疯狂的狮子Li 1 year ago committed by Gitee
commit bf95012138
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -242,16 +242,13 @@ public class OssClient {
* @throws OssException
*/
public Path fileDownload(String path) {
// 从路径中移除 URL 前缀
String url = removeBaseUrl(path);
// 构建临时文件路径 文件名必须是唯一不存在的,路径必须是存在的
Path tempFilePath = Paths.get(extractFileName(url));
// 构建临时文件
Path tempFilePath = FileUtils.createTempFile().toPath();
// 使用 S3TransferManager 下载文件
FileDownload downloadFile = transferManager.downloadFile(
x -> x.getObjectRequest(
y -> y.bucket(properties.getBucketName())
.key(url)
.key(removeBaseUrl(path))
.build())
.addTransferListener(LoggingTransferListener.create())
.destination(tempFilePath)
@ -451,16 +448,6 @@ public class OssClient {
return path.replace(getUrl() + StringUtils.SLASH, "");
}
/**
*
*
* @param path
* @return
*/
public String extractFileName(String path) {
return FileUtils.getTmpDir() + StringUtils.SLASH + Paths.get(path).getFileName().toString();
}
/**
*
*/

Loading…
Cancel
Save