|
@@ -6,33 +6,46 @@ import cn.hutool.core.util.RuntimeUtil;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.common.util.CmdUtils;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.io.File;
|
|
|
|
|
|
/**
|
|
|
* @author Xiewj
|
|
|
* @date 2024/1/12
|
|
|
*/
|
|
|
+@Component
|
|
|
@Slf4j
|
|
|
public class DownloadUtil {
|
|
|
+ @Resource
|
|
|
+ private FYunFileServiceInterface fYunFileService;
|
|
|
+ @Value("${download.config.resource-url}")
|
|
|
+ private String resourceUrl;
|
|
|
+ @Value("${download.config.laser-resource-url}")
|
|
|
+ private String laserResourceUrl;
|
|
|
+
|
|
|
public final static String WGET_CMD = "wget -t 10 -N -O @out @url";
|
|
|
|
|
|
- public static void downFile(String url, String path) throws Exception {
|
|
|
+ public void downFile(String url, String path) throws Exception {
|
|
|
String cmd = WGET_CMD.replace("@out",path).replace("@url",url);
|
|
|
RuntimeUtil.exec(cmd);
|
|
|
}
|
|
|
- public static void downloadFile(String url, String path,int index){
|
|
|
+ public void downloadFile(String url, String path,int index){
|
|
|
File file = new File(path);
|
|
|
if(!file.getParentFile().exists()){
|
|
|
file.getParentFile().mkdirs();
|
|
|
}
|
|
|
try {
|
|
|
- DownloadUtil.downFile(url,path);
|
|
|
+ HttpUtil.downloadFileFromUrl(url,path);
|
|
|
if(FileUtil.size(new File(path)) == 0){
|
|
|
while (index<=50){
|
|
|
index++;
|
|
|
- DownloadUtil.downFile(url,path);
|
|
|
+ HttpUtil.downloadFileFromUrl(url,path);
|
|
|
if (FileUtil.size(new File(path))>0){
|
|
|
log.info("文件第{}次下载成功:{}", index, path);
|
|
|
return;
|