S3 Bucket Downloader
Usage
example_download_s3_bucket.sh
python scripts/download_s3_bucket.py [-h] -b BUCKET -p PREFIX -o OUTPUT_DIR [-r REGION]
Download an S3 bucket with folder prefix.
optional arguments:
-h, --help show this help message and exit
-b BUCKET, --bucket BUCKET
S3 bucket name.
-p PREFIX, --prefix PREFIX
S3 folder prefix.
-o OUTPUT_DIR, --output_dir OUTPUT_DIR
Path to local output directory.
-r REGION, --region REGION
AWS region name.
Example
example_download_s3_bucket.sh
python scripts/download_s3_bucket.py --bucket="my_bucket" --prefix="recordings/" --output_dir="downloads/"
scripts.download_s3_bucket
parse_args(args)
Utility argument parser function for S3 bucket downloader.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args |
List[str] |
List of arguments. |
required |
Returns:
Type | Description |
---|---|
argparse.Namespace |
Objects with arguments values as attributes. |
Source code in scripts/download_s3_bucket.py
def parse_args(args: List[str]) -> argparse.Namespace:
"""
Utility argument parser function for S3 bucket downloader.
Args:
args (List[str]):
List of arguments.
Returns:
argparse.Namespace:
Objects with arguments values as attributes.
"""
parser = argparse.ArgumentParser(
prog="python scripts/download_s3_bucket.py",
description="Download an S3 bucket with folder prefix.",
)
parser.add_argument(
"-b", "--bucket", type=str, required=True, help="S3 bucket name."
)
parser.add_argument(
"-p", "--prefix", type=str, required=True, help="S3 folder prefix."
)
parser.add_argument(
"-o",
"--output_dir",
type=str,
required=True,
help="Path to local output directory.",
)
parser.add_argument(
"-r",
"--region",
type=str,
default="ap-southeast-1",
help="AWS region name.",
)
return parser.parse_args(args)