mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-09-13 16:34:53 +00:00
Refine archive preview and PDF defaults
This commit is contained in:
@@ -59,21 +59,26 @@ public class CompressFileReader {
|
||||
for (final ISimpleInArchiveItem item : simpleInArchive.getArchiveItems()) {
|
||||
if (!item.isFolder()) {
|
||||
final Path filePathInsideArchive = getFilePathInsideArchive(item, folderPath);
|
||||
ExtractOperationResult result = item.extractSlow(data -> {
|
||||
try (OutputStream out = new BufferedOutputStream(new FileOutputStream(filePathInsideArchive.toFile(), true))) {
|
||||
out.write(data);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return data.length;
|
||||
}, filePassword);
|
||||
if (result != ExtractOperationResult.OK) {
|
||||
ExtractOperationResult result1 = ExtractOperationResult.valueOf("WRONG_PASSWORD");
|
||||
if (result1.equals(result)) {
|
||||
throw new Exception("Password");
|
||||
}else {
|
||||
throw new Exception("Failed to extract RAR file.");
|
||||
Files.deleteIfExists(filePathInsideArchive);
|
||||
try (OutputStream out = new BufferedOutputStream(new FileOutputStream(filePathInsideArchive.toFile(), false))) {
|
||||
ExtractOperationResult result = item.extractSlow(data -> {
|
||||
try {
|
||||
out.write(data);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return data.length;
|
||||
}, filePassword);
|
||||
if (result != ExtractOperationResult.OK) {
|
||||
ExtractOperationResult result1 = ExtractOperationResult.valueOf("WRONG_PASSWORD");
|
||||
if (result1.equals(result)) {
|
||||
throw new Exception("Password");
|
||||
} else {
|
||||
throw new Exception("Failed to extract RAR file.");
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
FileType type = FileType.typeFromUrl(filePathInsideArchive.toString());
|
||||
@@ -110,4 +115,4 @@ public class CompressFileReader {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,4 +348,4 @@ public class OfficeFilePreviewImpl implements FilePreview {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user