boto3-assist 0.2.2__py3-none-any.whl → 0.2.3__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 CHANGED
@@ -139,7 +139,7 @@ class S3(S3Connection):
139
139
 
140
140
  return response
141
141
 
142
- def upload_file_obj(self, bucket: str, key: str, file_obj: bytes) -> str:
142
+ def upload_file_obj(self, bucket: str, key: str, file_obj: bytes | str) -> str:
143
143
  """
144
144
  Uploads a file object to s3. Returns the full s3 path s3://<bucket>/<key>
145
145
  """
@@ -156,6 +156,10 @@ class S3(S3Connection):
156
156
  }
157
157
  )
158
158
  try:
159
+ # convert if necessary
160
+ file_obj: bytes = (
161
+ file_obj.encode("utf-8") if isinstance(file_obj, str) else file_obj
162
+ )
159
163
  self.client.upload_fileobj(Fileobj=file_obj, Bucket=bucket, Key=key)
160
164
 
161
165
  except ClientError as ce:
@@ -503,3 +507,19 @@ class S3(S3Connection):
503
507
  else:
504
508
  # Not in AWS Lambda, use the system's default temp directory
505
509
  return tempfile.gettempdir()
510
+
511
+ def encode(
512
+ self, text: str, encoding: str = "utf-8", errors: str = "strict"
513
+ ) -> bytes:
514
+ """
515
+ Encodes a string for s3
516
+ """
517
+ return text.encode(encoding=encoding, errors=errors)
518
+
519
+ def decode(
520
+ self, file_obj: bytes, encoding: str = "utf-8", errors: str = "strict"
521
+ ) -> str:
522
+ """
523
+ Decodes bytes to a string
524
+ """
525
+ return file_obj.decode(encoding=encoding, errors=errors)
boto3_assist/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = '0.2.2'
1
+ __version__ = '0.2.3'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: boto3_assist
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Additional boto3 wrappers to make your life a little easier
5
5
  Author-email: Eric Wilson <boto3-assist@geekcafe.com>
6
6
  Classifier: License :: Other/Proprietary License
@@ -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=QQ0yjZQnvXM7JeLLZEZWX6NmVUPu1lSROWOXF49_gug,22
5
+ boto3_assist/version.py,sha256=XtWUl6HPylv5jZLd2KkgtPptuzuda93kC2REmOrF-Cs,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,7 +28,7 @@ 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=j-u-gLxCDHS4XFEsFGSdfr3QBUxqc95g0NBmQQ5Z1g0,15965
31
+ boto3_assist/s3/s3.py,sha256=sIjRMGsrRuQ0NZUP9tnfm_4e_Fx5RSpNKdCu5uToCyI,16592
32
32
  boto3_assist/s3/s3_connection.py,sha256=fMD1FxQazJ9gSFDrRmrv7YJE5QnCesGoWC1b5Dba_Jo,3774
33
33
  boto3_assist/utilities/datetime_utility.py,sha256=TbqGQkJDTahqvaZAIV550nhYnW1Bsq0Hdu3Go6P4RRs,10282
34
34
  boto3_assist/utilities/file_operations.py,sha256=HWQR6o3R5JaISixJS8CpUMsiNgW3Qp5yVZ9KA-jhPmA,3133
@@ -36,8 +36,8 @@ boto3_assist/utilities/http_utility.py,sha256=koFv7Va-8ng-47Nt1K2Sh7Ti95e62IYs9V
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.2.dist-info/METADATA,sha256=6oHYMJUemswTElxmH2QeESelggP2rLyppiMc-vm7oBQ,1742
40
- boto3_assist-0.2.2.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
41
- boto3_assist-0.2.2.dist-info/licenses/LICENSE-EXPLAINED.txt,sha256=WFREvTpfTjPjDHpOLADxJpCKpIla3Ht87RUUGii4ODU,606
42
- boto3_assist-0.2.2.dist-info/licenses/LICENSE.txt,sha256=PXDhFWS5L5aOTkVhNvoitHKbAkgxqMI2uUPQyrnXGiI,1105
43
- boto3_assist-0.2.2.dist-info/RECORD,,
39
+ boto3_assist-0.2.3.dist-info/METADATA,sha256=BTWNTK9P2fKTQ-7uQAN3S26ZE2wjZkOHC3QgOfDFu-E,1742
40
+ boto3_assist-0.2.3.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
41
+ boto3_assist-0.2.3.dist-info/licenses/LICENSE-EXPLAINED.txt,sha256=WFREvTpfTjPjDHpOLADxJpCKpIla3Ht87RUUGii4ODU,606
42
+ boto3_assist-0.2.3.dist-info/licenses/LICENSE.txt,sha256=PXDhFWS5L5aOTkVhNvoitHKbAkgxqMI2uUPQyrnXGiI,1105
43
+ boto3_assist-0.2.3.dist-info/RECORD,,