-
Notifications
You must be signed in to change notification settings - Fork 0
/
s3_upload.py
31 lines (26 loc) · 1.13 KB
/
s3_upload.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import argparse
import s3
parser = argparse.ArgumentParser(description='Upload file to S3 bucket.')
parser.add_argument('bucket', metavar='B', type=str, help='bucket name')
parser.add_argument('file', metavar='F', type=str, help='file to upload')
parser.add_argument('project', metavar='P', type=str, help='project it belongs to')
parser.add_argument('--type', action='store', help='type of the upload, possible values: asset, database, files')
parser.add_argument('--month', action='store_true', help='add monthly rotation policy')
parser.add_argument('--week', action='store_true', help='add weekly rotation policy')
parser.add_argument('--day', action='store_true', help='add daily rotation policy')
parser.add_argument('--hour', action='store_true', help='add hourly rotation policy')
args = parser.parse_args()
rotation_policy = s3.S3RotationPolicy(
month=args.month,
weekday=args.week,
day=args.day,
hour=args.hour
)
package = s3.S3UploadPackage(
file_path=args.file,
project=args.project,
upload_type=args.type,
rotation_policy=rotation_policy
)
service = s3.S3Handler(bucket_name=args.bucket)
service.upload(package)