boto3-assist 0.2.3__py3-none-any.whl → 0.2.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- boto3_assist/s3/s3.py +17 -1
- boto3_assist/utilities/file_operations.py +10 -0
- boto3_assist/version.py +1 -1
- {boto3_assist-0.2.3.dist-info → boto3_assist-0.2.4.dist-info}/METADATA +1 -1
- {boto3_assist-0.2.3.dist-info → boto3_assist-0.2.4.dist-info}/RECORD +8 -8
- {boto3_assist-0.2.3.dist-info → boto3_assist-0.2.4.dist-info}/WHEEL +0 -0
- {boto3_assist-0.2.3.dist-info → boto3_assist-0.2.4.dist-info}/licenses/LICENSE-EXPLAINED.txt +0 -0
- {boto3_assist-0.2.3.dist-info → boto3_assist-0.2.4.dist-info}/licenses/LICENSE.txt +0 -0
boto3_assist/s3/s3.py
CHANGED
|
@@ -7,6 +7,7 @@ MIT License. See Project Root for the license information.
|
|
|
7
7
|
import os
|
|
8
8
|
import tempfile
|
|
9
9
|
import time
|
|
10
|
+
import io
|
|
10
11
|
from typing import Any, Dict, List, Optional
|
|
11
12
|
|
|
12
13
|
from aws_lambda_powertools import Logger
|
|
@@ -50,6 +51,19 @@ class S3(S3Connection):
|
|
|
50
51
|
aws_secret_access_key=aws_secret_access_key,
|
|
51
52
|
)
|
|
52
53
|
|
|
54
|
+
def create_bucket(self, bucket_name: str) -> None:
|
|
55
|
+
"""
|
|
56
|
+
Create an S3 bucket
|
|
57
|
+
:param bucket_name: Bucket to create
|
|
58
|
+
:return: True if bucket is created, else False
|
|
59
|
+
"""
|
|
60
|
+
try:
|
|
61
|
+
self.client.create_bucket(Bucket=bucket_name)
|
|
62
|
+
logger.info(f"Bucket {bucket_name} created")
|
|
63
|
+
except ClientError as e:
|
|
64
|
+
logger.exception(e)
|
|
65
|
+
raise e
|
|
66
|
+
|
|
53
67
|
def generate_presigned_url(
|
|
54
68
|
self,
|
|
55
69
|
bucket_name: str,
|
|
@@ -160,7 +174,9 @@ class S3(S3Connection):
|
|
|
160
174
|
file_obj: bytes = (
|
|
161
175
|
file_obj.encode("utf-8") if isinstance(file_obj, str) else file_obj
|
|
162
176
|
)
|
|
163
|
-
self.client.upload_fileobj(
|
|
177
|
+
self.client.upload_fileobj(
|
|
178
|
+
Fileobj=io.BytesIO(file_obj), Bucket=bucket, Key=key
|
|
179
|
+
)
|
|
164
180
|
|
|
165
181
|
except ClientError as ce:
|
|
166
182
|
error = {
|
|
@@ -58,6 +58,16 @@ class FileOperations:
|
|
|
58
58
|
dirname = os.path.dirname(path)
|
|
59
59
|
return dirname
|
|
60
60
|
|
|
61
|
+
@staticmethod
|
|
62
|
+
def read_file(path: str, encoding: str = "utf-8") -> str:
|
|
63
|
+
"""
|
|
64
|
+
Read a file
|
|
65
|
+
"""
|
|
66
|
+
logger.debug(f"reading file {path}")
|
|
67
|
+
with open(path, "r", encoding=encoding) as file:
|
|
68
|
+
data = file.read()
|
|
69
|
+
return data
|
|
70
|
+
|
|
61
71
|
@staticmethod
|
|
62
72
|
def write_to_file(path: str, data: str, append: bool = False) -> str:
|
|
63
73
|
"""
|
boto3_assist/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '0.2.
|
|
1
|
+
__version__ = '0.2.4'
|
|
@@ -2,7 +2,7 @@ boto3_assist/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
2
2
|
boto3_assist/boto3session.py,sha256=NWhWtYR3143thEbTpoklkwdz77-fTMs-QsoQdqfRm6E,6430
|
|
3
3
|
boto3_assist/connection.py,sha256=EJlGueLIYqMSKs7aQlThK1S0Zkb8dOYBWch1iRZdgUI,3233
|
|
4
4
|
boto3_assist/connection_tracker.py,sha256=_s1t7h2DOi3CCIHIr_HIKyGjku65WR-HJ_v8vJHDvO0,2977
|
|
5
|
-
boto3_assist/version.py,sha256=
|
|
5
|
+
boto3_assist/version.py,sha256=N5-p8dQB8uwuCMpS1ADLf_E6rvWovtRRp3vY9Cq2gw4,22
|
|
6
6
|
boto3_assist/cloudwatch/cloudwatch_connection.py,sha256=mnGWaLSQpHh5EeY7Ek_2o9JKHJxOELIYtQVMX1IaHn4,2480
|
|
7
7
|
boto3_assist/cloudwatch/cloudwatch_connection_tracker.py,sha256=mzRtO1uHrcfJNh1XrGEiXdTqxwEP8d1RqJkraMNkgK0,410
|
|
8
8
|
boto3_assist/cloudwatch/cloudwatch_log_connection.py,sha256=qQMZHjUJ6gA8wU9utjQhOURXNSPH2RjxSoAy83bvoCs,1737
|
|
@@ -28,16 +28,16 @@ boto3_assist/environment_services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeR
|
|
|
28
28
|
boto3_assist/environment_services/environment_loader.py,sha256=jvG1xwMtgkZqu70NbjG1b1IefKiWgaidjZZoqsSfULk,3370
|
|
29
29
|
boto3_assist/environment_services/environment_variables.py,sha256=4ccBKdPt6O7hcRT3zBHd8vqu8yQU8udmoD5RLAT3iMs,6801
|
|
30
30
|
boto3_assist/errors/custom_exceptions.py,sha256=zC2V2Y4PUtKj3uLPn8mB-JessksKWJWvKM9kp1dmvt8,760
|
|
31
|
-
boto3_assist/s3/s3.py,sha256=
|
|
31
|
+
boto3_assist/s3/s3.py,sha256=NdfoU_vcg8ypyC2iYKm236zYTB3V7ave5vc_6Mdscxc,17065
|
|
32
32
|
boto3_assist/s3/s3_connection.py,sha256=fMD1FxQazJ9gSFDrRmrv7YJE5QnCesGoWC1b5Dba_Jo,3774
|
|
33
33
|
boto3_assist/utilities/datetime_utility.py,sha256=TbqGQkJDTahqvaZAIV550nhYnW1Bsq0Hdu3Go6P4RRs,10282
|
|
34
|
-
boto3_assist/utilities/file_operations.py,sha256=
|
|
34
|
+
boto3_assist/utilities/file_operations.py,sha256=Zy8fu8fpuVNf7U9NimrLdy5FRF71XSI159cnRdzmzGY,3411
|
|
35
35
|
boto3_assist/utilities/http_utility.py,sha256=koFv7Va-8ng-47Nt1K2Sh7Ti95e62IYs9VMLlGh9Kt4,1173
|
|
36
36
|
boto3_assist/utilities/logging_utility.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
37
37
|
boto3_assist/utilities/serialization_utility.py,sha256=s_QQRIhtwIE7xN5nU13mNk2wtWyErBX_Sg7n0gbHj-M,4308
|
|
38
38
|
boto3_assist/utilities/string_utility.py,sha256=w8l063UT3GE48tuJopETyZrjG4CgAzWkyDWMAYMg5Og,7432
|
|
39
|
-
boto3_assist-0.2.
|
|
40
|
-
boto3_assist-0.2.
|
|
41
|
-
boto3_assist-0.2.
|
|
42
|
-
boto3_assist-0.2.
|
|
43
|
-
boto3_assist-0.2.
|
|
39
|
+
boto3_assist-0.2.4.dist-info/METADATA,sha256=6-R1661w1pMbKim2BiW3_Fq_rdVte73z5FM9oTmgyI4,1742
|
|
40
|
+
boto3_assist-0.2.4.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
41
|
+
boto3_assist-0.2.4.dist-info/licenses/LICENSE-EXPLAINED.txt,sha256=WFREvTpfTjPjDHpOLADxJpCKpIla3Ht87RUUGii4ODU,606
|
|
42
|
+
boto3_assist-0.2.4.dist-info/licenses/LICENSE.txt,sha256=PXDhFWS5L5aOTkVhNvoitHKbAkgxqMI2uUPQyrnXGiI,1105
|
|
43
|
+
boto3_assist-0.2.4.dist-info/RECORD,,
|
|
File without changes
|
{boto3_assist-0.2.3.dist-info → boto3_assist-0.2.4.dist-info}/licenses/LICENSE-EXPLAINED.txt
RENAMED
|
File without changes
|
|
File without changes
|