孙永军 1 rok temu
rodzic
commit
b3c591852a

+ 1 - 1
build.gradle

@@ -64,7 +64,7 @@ dependencies {
     implementation 'cn.hutool:hutool-poi:5.7.20'
     implementation 'org.apache.poi:poi:5.0.0'
     implementation 'org.apache.poi:poi-ooxml:5.0.0'
-    implementation 'com.alibaba:easyexcel:2.2.6'
+//    implementation 'com.alibaba:easyexcel:2.2.6'
     implementation 'org.springframework.retry:spring-retry:1.3.1'
 
     implementation 'com.aliyun.oss:aliyun-sdk-oss:3.10.2'

+ 4 - 2
src/main/java/com/sxtvs/open/api/h5template/service/impl/OSSService.java

@@ -163,20 +163,22 @@ public class OSSService {
         // 读取DOC文件
         ByteArrayInputStream fis = new ByteArrayInputStream(IoUtil.readBytes(file.getInputStream()));
 
+        XWPFDocument xwpfDocument = new XWPFDocument();
         HWPFDocument document = new HWPFDocument(fis);
 
         WordExtractor wordExtractor = new WordExtractor(document);
         String text = wordExtractor.getText();
-        XWPFDocument xwpfDocument = new XWPFDocument();
         XWPFParagraph paragraph = xwpfDocument.createParagraph();
         XWPFRun run = paragraph.createRun();
         run.setText(text);
+
         ByteArrayOutputStream fos = new ByteArrayOutputStream();
         xwpfDocument.write(fos);
 
         String dir = "open/bid/" + id + "/";
         String fileUrl = dir + file.getOriginalFilename() + "x";
-        ossClient.putObject(bucket, fileUrl , xwpfDocument.getDocument().newInputStream());
+        ossClient.putObject(bucket, fileUrl , new ByteArrayInputStream(fos.toByteArray()));
+        fos.close();
         fis.reset();
 
         String encodedString = URLEncoder.encode(fileUrl, StandardCharsets.UTF_8);