package com.xhpc.system.utils;

import cn.hutool.http.HttpUtil;
import com.xhpc.common.core.utils.StringUtils;

import java.io.File;

public class DownloadUtil {

    public static File downloadFile(String fileUrl) throws Exception {

        if (StringUtils.isEmpty(fileUrl)) {
            throw new Exception("文件地址为空");
        }
        String suffix = fileUrl.substring(fileUrl.lastIndexOf("."));
        return HttpUtil.downloadFileFromUrl(fileUrl, File.createTempFile("temp_", suffix));
    }
}
