Reading Partial Zip content #505
TJ-Edwards
started this conversation in
General
Replies: 1 comment 7 replies
-
You're using the legacy version of zip.js (i.e. < 2.x) which has been abandoned more than 4 years ago. You have to update zip.js to the last version. |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am having an issue with parsing a partial zip request. My scenario is that I need to be able to read images out of the archive, but due to the size I want to retrieve the content in chunks. However, I believe I am missing something. Whenever I try to process my blob, I get the following error.
//blob
size: 1124376968
type: "application/zip"
//Error
ZipExtractor.ts:23 ERROR Error: Uncaught (in promise): File format is not recognized.
Currently I am just retrieving a random byte range based on the archive size. This is a very temporary approach to see if partial reads could be accomplished. I realize I might be cutting files off because I dont have the central directory. I plan on getting that from an external source and not the library itself. Does anyone see this as being a potential problem?
For a bit more context I am using the ZipExtractor class provided in the repo for parsing the blob. I did some messing around to force the blob type to see if that would help, but that did not work out.
//ZipExtractor.ts
export interface ZipContent {
[filePath: string]: {
name: string
content: string
}
}
export class ZipExtractor {
public extract(zipData: Blob): Promise {
zipData = zipData.slice(0, zipData.size, "application/zip");
let zipContent: ZipContent = {};
return new Promise((resolve, reject) => {
zip.createReader(new zip.BlobReader(zipData), (zipReader) => {
let beginDate: Date = new Date();
console.info(
zip reader opened at ${beginDate}
, zipData);}
Any guidance here would be greatly appreciated! Thank you for your time.
Beta Was this translation helpful? Give feedback.
All reactions