Basit
Basit

Reputation: 17184

gzip or deflate files can it be merged together? for api

i have api that let you get one or more files content in one request and i have them as deflate/gzip and normal text, for now im using normal text, but was wondering if i can merge deflate files and sent back on the request as i do for normal, will it still work?

i tried some testing, but only one file content shows in browser and other dont, but i saw there is some example of sending multiple gzip files on fly as zip file. so i wanted to know if its possible and if yes, then how can i do it.

Upvotes: 1

Views: 571

Answers (1)

Marc B
Marc B

Reputation: 360702

gzip only supports a single file internally. It's not a container format, just a straight deflation. There's no provision to maintain a directory of where one file ends and another starts, let along the file metadata (filename, creation date, size, etc...)

You can use .tar to glom multiple files together, and then gzip the .tar file. Or use zip to wrap multiple files (of any type) into a single .zip file. Since you say you'd be zipping .gz'd files, I'd suggest just using zip as a container, with compression disabled. The few bytes you'd save by recompressing the .gz files won't be worth the CPU overhead to do the extra compression run.

Upvotes: 1

Related Questions