| | |
| | | import org.sxkj.resource.vo.AttachTypeStatisticsVO; |
| | | import org.sxkj.resource.vo.AttachVO; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | |
| | | } |
| | | @Override |
| | | public BladeFile saveAttachFile(MultipartFile file, String fileName) throws IOException { |
| | | BladeFile bladeFile = ossBuilder.template().putFile(pojo.getBucket(),fileName, file.getInputStream()); |
| | | // 步骤1: 将文件转换为字节数组,避免流重置异常 |
| | | byte[] bytes = file.getBytes(); |
| | | // 步骤2: 使用字节数组输入流上传文件 |
| | | BladeFile bladeFile = ossBuilder.template().putFile(pojo.getBucket(),fileName, new ByteArrayInputStream(bytes)); |
| | | Long attachId = buildAttach(fileName, file.getSize(), bladeFile, null); |
| | | bladeFile.setAttachId(attachId); |
| | | return bladeFile; |
| | |
| | | |
| | | @Override |
| | | public BladeFile saveAttachFile(MultipartFile file, String fileName, List<List<String>> type) throws IOException { |
| | | BladeFile bladeFile = ossBuilder.template().putFile(pojo.getBucket(),fileName, file.getInputStream()); |
| | | // 步骤1: 将文件转换为字节数组,避免流重置异常 |
| | | byte[] bytes = file.getBytes(); |
| | | // 步骤2: 使用字节数组输入流上传文件 |
| | | BladeFile bladeFile = ossBuilder.template().putFile(pojo.getBucket(),fileName, new ByteArrayInputStream(bytes)); |
| | | Long attachId = buildAttach(fileName, file.getSize(), bladeFile, type); |
| | | bladeFile.setAttachId(attachId); |
| | | return bladeFile; |
| | |
| | | */ |
| | | @Override |
| | | public BladeFile putFile(MultipartFile file, String fileName) throws IOException { |
| | | BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream()); |
| | | // 步骤1: 将文件转换为字节数组,避免流重置异常 |
| | | byte[] bytes = file.getBytes(); |
| | | // 步骤2: 使用字节数组输入流上传文件 |
| | | BladeFile bladeFile = ossBuilder.template().putFile(fileName, new ByteArrayInputStream(bytes)); |
| | | return bladeFile; |
| | | } |
| | | |