commit
5ed90911bb
@ -1,5 +1,6 @@
|
|||||||
package com.qiwenshare.file.service;
|
package com.qiwenshare.file.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
@ -264,7 +265,7 @@ public class FiletransferService implements IFiletransferService {
|
|||||||
public void downloadFile(HttpServletResponse httpServletResponse, DownloadFileDTO downloadFileDTO) {
|
public void downloadFile(HttpServletResponse httpServletResponse, DownloadFileDTO downloadFileDTO) {
|
||||||
UserFile userFile = userFileMapper.selectById(downloadFileDTO.getUserFileId());
|
UserFile userFile = userFileMapper.selectById(downloadFileDTO.getUserFileId());
|
||||||
|
|
||||||
if (userFile.getIsDir() == 0) {
|
if (userFile.isFile()) {
|
||||||
|
|
||||||
FileBean fileBean = fileMapper.selectById(userFile.getFileId());
|
FileBean fileBean = fileMapper.selectById(userFile.getFileId());
|
||||||
Downloader downloader = ufopFactory.getDownloader(fileBean.getStorageType());
|
Downloader downloader = ufopFactory.getDownloader(fileBean.getStorageType());
|
||||||
@ -309,7 +310,7 @@ public class FiletransferService implements IFiletransferService {
|
|||||||
try {
|
try {
|
||||||
for (String userFileId : userFileIds) {
|
for (String userFileId : userFileIds) {
|
||||||
UserFile userFile1 = userFileMapper.selectById(userFileId);
|
UserFile userFile1 = userFileMapper.selectById(userFileId);
|
||||||
if (userFile1.getIsDir() == 0) {
|
if (userFile1.isFile()) {
|
||||||
FileBean fileBean = fileMapper.selectById(userFile1.getFileId());
|
FileBean fileBean = fileMapper.selectById(userFile1.getFileId());
|
||||||
Downloader downloader = ufopFactory.getDownloader(fileBean.getStorageType());
|
Downloader downloader = ufopFactory.getDownloader(fileBean.getStorageType());
|
||||||
if (downloader == null) {
|
if (downloader == null) {
|
||||||
@ -321,7 +322,7 @@ public class FiletransferService implements IFiletransferService {
|
|||||||
InputStream inputStream = downloader.getInputStream(downloadFile);
|
InputStream inputStream = downloader.getInputStream(downloadFile);
|
||||||
BufferedInputStream bis = new BufferedInputStream(inputStream);
|
BufferedInputStream bis = new BufferedInputStream(inputStream);
|
||||||
try {
|
try {
|
||||||
QiwenFile qiwenFile = new QiwenFile(userFile1.getFilePath().replaceFirst(filePath, ""), userFile1.getFileName() + "." + userFile1.getExtendName(), false);
|
QiwenFile qiwenFile = new QiwenFile(StrUtil.removePrefix(userFile1.getFilePath(), filePath), userFile1.getFileName() + "." + userFile1.getExtendName(), false);
|
||||||
zos.putNextEntry(new ZipEntry(qiwenFile.getPath()));
|
zos.putNextEntry(new ZipEntry(qiwenFile.getPath()));
|
||||||
|
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024];
|
||||||
@ -342,7 +343,7 @@ public class FiletransferService implements IFiletransferService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QiwenFile qiwenFile = new QiwenFile(userFile1.getFilePath(), userFile1.getFileName(), true);
|
QiwenFile qiwenFile = new QiwenFile(StrUtil.removePrefix(userFile1.getFilePath(), filePath), userFile1.getFileName(), true);
|
||||||
// 空文件夹的处理
|
// 空文件夹的处理
|
||||||
zos.putNextEntry(new ZipEntry(qiwenFile.getPath() + QiwenFile.separator));
|
zos.putNextEntry(new ZipEntry(qiwenFile.getPath() + QiwenFile.separator));
|
||||||
// 没有文件,不需要文件的copy
|
// 没有文件,不需要文件的copy
|
||||||
|
Loading…
Reference in New Issue
Block a user