|
@@ -19,14 +19,12 @@ import com.doc.common.utils.poi.ExcelUtil;
|
|
|
import io.swagger.annotations.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.data.elasticsearch.NoSuchIndexException;
|
|
|
-import org.springframework.util.ResourceUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
+import java.io.InputStream;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -125,34 +123,34 @@ public class DocInfoController extends BaseController {
|
|
|
})
|
|
|
public AjaxResult create(Long spaceId, Long dirId, String type) {
|
|
|
try {
|
|
|
- File file = null;
|
|
|
+ String filePath = "";
|
|
|
String fileName = "";
|
|
|
switch (type) {
|
|
|
case "word":
|
|
|
- file = ResourceUtils.getFile("classpath:file/new.docx");
|
|
|
+ filePath = "file/new.docx";
|
|
|
fileName = "新建word文档.docx";
|
|
|
break;
|
|
|
case "excel":
|
|
|
- file = ResourceUtils.getFile("classpath:file/new.xlsx");
|
|
|
+ filePath = "file/new.xlsx";
|
|
|
fileName = "新建Excel文档.xlsx";
|
|
|
break;
|
|
|
case "ppt":
|
|
|
- file = ResourceUtils.getFile("classpath:file/new.pptx");
|
|
|
+ filePath = "file/new.pptx";
|
|
|
fileName = "新建ppt文档.pptx";
|
|
|
break;
|
|
|
case "txt":
|
|
|
- file = ResourceUtils.getFile("classpath:file/new.txt");
|
|
|
+ filePath = "file/new.txt";
|
|
|
fileName = "新建文本文档.txt";
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- FileInputStream is = new FileInputStream(file);
|
|
|
+ InputStream is = this.getClass().getResourceAsStream("/" + filePath);
|
|
|
MultipartFile multipartFile = FileUtils.getMultipartFile(is, fileName);
|
|
|
DocumentVO vo = mongoService.uploadFile(multipartFile);
|
|
|
process(vo, spaceId, dirId);
|
|
|
return success();
|
|
|
} catch (Exception e) {
|
|
|
- log.error("新建文件出错啦", e.getMessage());
|
|
|
+ log.error("新建文件出错啦:{}", e.getMessage());
|
|
|
return error("新建文件出错");
|
|
|
}
|
|
|
}
|