Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ optional arguments:
ADVANCED: Max retries for each request the s3 client makes
--part-size-multiplier PART_SIZE_MULTIPLIER
ADVANCED: Multiplied by 5MB to set the max size of each upload chunk
--storage-class STORAGE_CLASS
ADVANCED: Storage class selector (Defaults to 'STANDARD', see s3 documentation for valid choices)
```


Expand Down
9 changes: 9 additions & 0 deletions s3_tar/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ def create_parser():
type=int,
default=10,
)
parser.add_argument(
"--storage-class",
help=("ADVANCED: Storage class selector"
" Valid choices are: STANDARD | REDUCED_REDUNDANCY | STANDARD_IA"
" | ONEZONE_IA | INTELLIGENT_TIERING | GLACIER | DEEP_ARCHIVE."
" Defaults to 'STANDARD'"),
default='STANDARD',
)

return parser

Expand All @@ -105,6 +113,7 @@ def cli():
allow_dups=args.allow_dups,
s3_max_retries=args.s3_max_retries,
part_size_multiplier=args.part_size_multiplier,
storage_class=args.storage_class,
) # pragma: no cover
job.add_files(
args.folder,
Expand Down
4 changes: 3 additions & 1 deletion s3_tar/s3_mpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@

class S3MPU:

def __init__(self, s3, target_bucket, target_key):
def __init__(self, s3, target_bucket, target_key, storage_class):
self.s3 = s3
self.target_bucket = target_bucket
self.target_key = target_key
self.storage_class = storage_class
self.parts_mapping = []

logger.info("Creating file {}".format(self.target_key))
self.resp = self.s3.create_multipart_upload(
Bucket=self.target_bucket,
Key=self.target_key,
StorageClass=self.storage_class,
)
logger.debug("Multipart upload start: {}".format(self.resp))

Expand Down
5 changes: 4 additions & 1 deletion s3_tar/s3_tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self, source_bucket, target_key,
allow_dups=False,
s3_max_retries=4,
part_size_multiplier=None,
storage_class='STANDARD',
session=boto3.session.Session()):
self.allow_dups = allow_dups
self.source_bucket = source_bucket
Expand Down Expand Up @@ -67,6 +68,8 @@ def __init__(self, source_bucket, target_key,
self.part_size_multiplier = 10
self.part_size_multiplier = part_size_multiplier

self.storage_class = storage_class

self.all_keys = set() # Keys the user adds
self.keys_to_delete = set() # Keys to delete on cleanup
self.remove_keys = remove_keys
Expand Down Expand Up @@ -132,7 +135,7 @@ def _new_file_upload(self, file_number):
result_filepath = self._add_file_number(file_number)

# Start multipart upload
mpu = S3MPU(self.s3, self.target_bucket, result_filepath)
mpu = S3MPU(self.s3, self.target_bucket, result_filepath, self.storage_class)

current_file_size = 0
# If out of files or min size is met, then complete file
Expand Down