feat: 压缩改为tar.gz
This commit is contained in:
@@ -47,7 +47,6 @@ import org.agt.module.system.api.mail.MailSendApi;
|
|||||||
import org.agt.module.system.api.mail.dto.MailSendSingleToUserReqDTO;
|
import org.agt.module.system.api.mail.dto.MailSendSingleToUserReqDTO;
|
||||||
import org.agt.module.system.api.notify.NotifyMessageSendApi;
|
import org.agt.module.system.api.notify.NotifyMessageSendApi;
|
||||||
import org.agt.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
|
import org.agt.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
|
||||||
import org.apache.commons.compress.archivers.ArchiveStreamFactory;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -1006,21 +1005,21 @@ public class LicenseServiceImpl implements LicenseService {
|
|||||||
.eq(LicenseDetailDO::getLicenseId, id));
|
.eq(LicenseDetailDO::getLicenseId, id));
|
||||||
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
Archiver archiver = CompressUtil.createArchiver(CharsetUtil.CHARSET_UTF_8, ArchiveStreamFactory.TAR, outputStream);
|
Archiver archiver = CompressUtil.createArchiver(CharsetUtil.CHARSET_UTF_8, "tar.gz", outputStream);
|
||||||
|
|
||||||
for (LicenseDetailDO detail : detailList) {
|
for (LicenseDetailDO detail : detailList) {
|
||||||
addArchiverFile(archiver, detail.getFileUrl());
|
addArchiverFile(archiver, detail.getFileUrl());
|
||||||
addArchiverFile(archiver, detail.getFileUrlLegacy());
|
addArchiverFile(archiver, detail.getFileUrlLegacy());
|
||||||
}
|
}
|
||||||
archiver.finish().close();
|
archiver.finish().close();
|
||||||
FileTypeUtils.writeAttachment(response, "temp.tar", outputStream.toByteArray());
|
FileTypeUtils.writeAttachment(response, "temp.tar.gz", outputStream.toByteArray());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw exception(LICENSE_DOWNLOAD_FAILED);
|
throw exception(LICENSE_DOWNLOAD_FAILED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addArchiverFile(Archiver archiver, String fileUrl) {
|
private void addArchiverFile(Archiver archiver, String fileUrl) {
|
||||||
String tempFilePath = "/usr/local/licGen/";
|
String tempFilePath = "/opt/agt/temp/";
|
||||||
if (StrUtil.isNotBlank(fileUrl)) {
|
if (StrUtil.isNotBlank(fileUrl)) {
|
||||||
String fileName = fileUrl.substring(fileUrl.lastIndexOf("/") + 1, fileUrl.lastIndexOf("_")) + ".ini";
|
String fileName = fileUrl.substring(fileUrl.lastIndexOf("/") + 1, fileUrl.lastIndexOf("_")) + ".ini";
|
||||||
CommonResult<byte[]> result = fileApi.getFileContent(fileUrl);
|
CommonResult<byte[]> result = fileApi.getFileContent(fileUrl);
|
||||||
|
|||||||
Reference in New Issue
Block a user