| | |
| | | DncBackFile backFIle = this.getById(id); |
| | | |
| | | return ZipTextFileContentUtil.getTextContent(this.ossTemplate.statFileStream(backFIle.getOssName()),entryName); |
| | | /* |
| | | try(InputStream inputStream = this.ossTemplate.statFileStream(backFIle.getOssName());){ |
| | | Path tempZipFile = createTempFile(inputStream); |
| | | |
| | | ZipEntry entry; |
| | | try (java.util.zip.ZipFile zipFile = new java.util.zip.ZipFile(tempZipFile.toFile())) { |
| | | Enumeration<? extends ZipEntry> entries = zipFile.entries(); |
| | | while (entries.hasMoreElements()) { |
| | | entry = entries.nextElement(); |
| | | if (!entryName.equals(entry.getName())) { |
| | | continue; |
| | | } |
| | | try (InputStream fileIns = zipFile.getInputStream(zipFile.getEntry(entryName))) { |
| | | ByteArrayInputStream bos = new ByteArrayInputStream(fileIns.readAllBytes()); |
| | | boolean isText = StringUtils.endsWithIgnoreCase(entryName,".txt") || StringUtils.endsWithIgnoreCase(entryName,".nc")|| StringUtils.endsWithIgnoreCase(entryName,".xml"); |
| | | if(!isText) { |
| | | isText = FileContentUtil.isTextFile(bos); |
| | | } |
| | | if (isText) { |
| | | bos.reset(); |
| | | result = FileContentUtil.getContentFromStream(bos); |
| | | } else { |
| | | result = "<非文本文件>"; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | }*/ |
| | | |
| | | |
| | | } |
| | | } |