Zipspy
zipspy is a CLI tool to extract files from zip archives in S3 without needing to download the entire archive
Preamble
The zipspy CLI allows you to download specific files and directories from a zip archive in S3 without having to download the entire object.
Installation
To install zipspy, run the following command:
go get github.com/alec-rabold/zipspy
Check that it's installed correctly by running:
zipspy version
Sample Flow
Be sure to set your AWS environment variables before using zipspy:
export AWS_PROFILE={profile}
export AWS_DEFAULT_REGION={region}
The following is an example of how to use the CLI, downloading a file called plan.txt
from an S3 zip archive called archive.zip
in a bucket named zipspy-test
. By default, the result is printed to stdout.
zipspy extract -b zipspy-test -k archive.zip -f plan.txt
You can specify multiple files and/or files paths. Zipspy will download all files whose filepaths contain the given input string. For example:
With an archive.zip
that has the following structure:
archive/
├── plan.txt
├── foldername1/
├── plan.txt
└── technology.md
├── foldername2/
├── plan.txt
└── header.html
zipspy extract -b zipspy-test -k archive.zip -f foldername2 -f plan.txt
will download the following files:
archive/plan.txt
archive/foldername1/plan.txt
archive/foldername2/plan.txt
archive/foldername2/header.html
zipspy extract -b zipspy-test -k archive.zip -f foldername2/plan.txt
will only download:
archive/foldername2/plan.txt
You may also specify output paths to write the file content to. By default, downloaded data will be appended to the specified file(s). If they don't exist, zipspy will create them.
The following example demonstrates how to download a file named plan.txt
and save it to data/my-plan.txt
.
zipspy extract -b zipspy-test -k archive.zip -f plan.txt -o data/my-plan.txt
You may specify any number of output files as long as there is an equal number of files to download.
zipspy extract -b zipspy-test -k archive.zip -f plan.txt -o data/my-plan.txt -f file.md -o data/file.md