优化zip下载功能

master
gongzhenkun 2 years ago
parent 4aa2040982
commit e1f105ebd4

@ -155,7 +155,7 @@ public class TRecordController extends BaseController
exportInfo.add(map);
});
}
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
// response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
try {
// FileUtils.setAttachmentResponseHeader(response, "舌面舌下图片下载");
// FileUtils.urlResourceWriteBytes(exportInfo, response.getOutputStream());

@ -163,11 +163,12 @@ public class FileUtils
bufIn = new BufferedInputStream(file.openStream());
zipEntry = new ZipEntry(filePath.get("downloadPath").toString());
zipOutputStream.putNextEntry(zipEntry);
int length = 0;
while ((length = bufIn.read()) != -1)
{
zipOutputStream.write(length);
}
// int length = 0;
// while ((length = bufIn.read()) != -1)
// {
// zipOutputStream.write(length);
// }
IOUtils.copy(bufIn,zipOutputStream);
}
}
catch (IOException e)
@ -213,12 +214,13 @@ public class FileUtils
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);
}
// byte[] b = new byte[1024*4];
// int length;
// while ((length = bufIn.read(b)) > 0)
// {
// zipOutputStream.write(b, 0, length);
// }
IOUtils.copy(bufIn,zipOutputStream);
}
}
catch (IOException e)

@ -1,6 +1,6 @@
package com.ruoyi.system.domain;
import com.ruoyi.common.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -42,6 +42,7 @@ public class TDownloadZip extends BaseEntity
/** 创建时间 */
@ApiModelProperty("创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
public void setId(Long id) {

Loading…
Cancel
Save