|
@@ -164,24 +164,19 @@ public class MinioTemplate implements FileStorageTemplate {
|
|
|
InnerUtils.checkArgument(pathKey != null && pathKey.length() > 0, "pathKey can't be empty");
|
|
|
InnerUtils.checkArgument(file != null && file.length() > 0, "file can't be empty");
|
|
|
|
|
|
- InputStream in=null;
|
|
|
|
|
|
log.info("下载开始:下载bucket={},下载pathKey={},下载filePath={}", bucket, pathKey, file);
|
|
|
try {
|
|
|
- GetObjectArgs objectArgs = GetObjectArgs.builder().object(pathKey)
|
|
|
- .bucket(bucket).build();
|
|
|
- in = minioClient.getObject(objectArgs);
|
|
|
+ File downloadFile = new File(file);
|
|
|
+ if (!FileUtil.exist(downloadFile.getParent())&&downloadFile.isDirectory()){
|
|
|
+ FileUtil.mkdir(downloadFile.getParent());
|
|
|
+ }
|
|
|
+ DownloadObjectArgs objectArgs = DownloadObjectArgs.builder().object(pathKey)
|
|
|
+ .bucket(bucket).filename(file).build();
|
|
|
+ minioClient.downloadObject(objectArgs);
|
|
|
return null;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- }finally {
|
|
|
- if(in!=null){
|
|
|
- try {
|
|
|
- in.close();
|
|
|
- } catch (IOException e) {
|
|
|
- log.error(e.getMessage(), e);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
@@ -201,6 +196,7 @@ public class MinioTemplate implements FileStorageTemplate {
|
|
|
InputStream in=null;
|
|
|
try {
|
|
|
in = minioClient.getObject(objectArgs);
|
|
|
+ handler.accept(in);
|
|
|
return null;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|