(feat): chalice - S3_DISABLE_SSL_VERIFY cast bool

This commit is contained in:
Dayan Graham 2023-03-27 16:55:25 +00:00
parent 516b90c5e1
commit 8ed2ca7792

View file

@ -17,7 +17,7 @@ else:
aws_secret_access_key=config("S3_SECRET"),
config=Config(signature_version='s3v4'),
region_name=config("sessions_region"),
verify=(False if config("S3_DISABLE_SSL_VERIFY") else True))
verify=not config("S3_DISABLE_SSL_VERIFY", default=False, cast=bool))
def __get_s3_resource():
@ -28,7 +28,7 @@ def __get_s3_resource():
aws_secret_access_key=config("S3_SECRET"),
config=Config(signature_version='s3v4'),
region_name=config("sessions_region"),
verify=(False if config("S3_DISABLE_SSL_VERIFY") else True))
verify=not config("S3_DISABLE_SSL_VERIFY", default=False, cast=bool))
def exists(bucket, key):
@ -83,7 +83,8 @@ def get_presigned_url_for_upload_secure(bucket, expires_in, key, conditions=None
Conditions=conditions,
)
req = PreparedRequest()
req.prepare_url(f"{url_parts['url']}/{url_parts['fields']['key']}", url_parts['fields'])
req.prepare_url(
f"{url_parts['url']}/{url_parts['fields']['key']}", url_parts['fields'])
return req.url
@ -103,7 +104,8 @@ def get_file(source_bucket, source_key):
def rename(source_bucket, source_key, target_bucket, target_key):
s3 = __get_s3_resource()
s3.Object(target_bucket, target_key).copy_from(CopySource=f'{source_bucket}/{source_key}')
s3.Object(target_bucket, target_key).copy_from(
CopySource=f'{source_bucket}/{source_key}')
s3.Object(source_bucket, source_key).delete()