| | |
| | | if ("xls".equals(ext)) { |
| | | return extractXls(bytes); |
| | | } |
| | | if (isImage(ext)) { |
| | | return "图片文件:" + filename + ",已上传,请结合图片内容识别采购单据、表格和产品明细。"; |
| | | } |
| | | throw new IllegalArgumentException("暂不支持该文件类型: " + ext); |
| | | } |
| | | |
| | | public boolean isImageFile(MultipartFile file) { |
| | | if (file == null) { |
| | | return false; |
| | | } |
| | | return isImage(getExtension(file.getOriginalFilename())); |
| | | } |
| | | |
| | | private String extractDocx(byte[] bytes) throws IOException { |
| | |
| | | "txt", "md", "markdown", "json", "xml", "yaml", "yml", "csv", "log", "properties", |
| | | "java", "js", "ts", "vue", "html", "css", "sql", "py", "go", "sh", "bat"); |
| | | } |
| | | |
| | | private boolean isImage(String ext) { |
| | | return StringUtils.inStringIgnoreCase(ext, "png", "jpg", "jpeg", "webp", "bmp"); |
| | | } |
| | | } |