优化zip下载功能

master
gongzhenkun 2 years ago
parent e1f105ebd4
commit 8052c62406

@ -24,6 +24,8 @@ import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.misc.BASE64Decoder;
/**
@ -33,6 +35,8 @@ import sun.misc.BASE64Decoder;
*/
public class FileUtils
{
private static final Logger logger = LoggerFactory.getLogger(FileUtils.class);
public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
/**
@ -210,17 +214,15 @@ public class FileUtils
fileOut = new FileOutputStream(desc);
zipOutputStream = new ZipOutputStream(fileOut);
for(Map<String,Object> filePath:filePathList){
try{
URL file = new URL(filePath.get("urlPath").toString());
bufIn = new BufferedInputStream(file.openStream());
zipEntry = new ZipEntry(filePath.get("downloadPath").toString());
zipOutputStream.putNextEntry(zipEntry);
// byte[] b = new byte[1024*4];
// int length;
// while ((length = bufIn.read(b)) > 0)
// {
// zipOutputStream.write(b, 0, length);
// }
IOUtils.copy(bufIn,zipOutputStream);
}catch (Exception ee){
logger.error("downloadLocalZip方法图片下载失败"+filePath.get("urlPath").toString()+"地址的图片访问失败",ee);
}
}
}
catch (IOException e)

Loading…
Cancel
Save