包头从mino下载文件,创建文件夹
This commit is contained in:
parent
9654d25975
commit
8505fd410a
@ -19,6 +19,7 @@ import javax.annotation.PostConstruct;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @description: minio工具类
|
||||
@ -46,10 +47,21 @@ public class MinioUtils {
|
||||
*/
|
||||
public static File downloadFile(String path) {
|
||||
File file = new File(PathUtil.getBasePath() + "/" + path);
|
||||
FileOutputStream stream = null;
|
||||
try {
|
||||
HttpUtil.download(PathUtil.getDomain() + path, new FileOutputStream(file), true);
|
||||
} catch (FileNotFoundException e) {
|
||||
FileUtil.mkdir(file.getParentFile());
|
||||
stream = new FileOutputStream(file);
|
||||
HttpUtil.download(PathUtil.getDomain() + path, stream, true);
|
||||
} catch (Exception e) {
|
||||
log.error("" + e);
|
||||
} finally {
|
||||
if (stream != null) {
|
||||
try {
|
||||
stream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user