pyaws-s3 1.0.20__py3-none-any.whl → 1.0.22__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.
pyaws_s3/s3.py CHANGED
@@ -172,6 +172,65 @@ class S3Client:
172
172
  logger.info(f"Pre-signed URL: {temp_url}")
173
173
 
174
174
  return temp_url
175
+
176
+ def upload_bytes(self, *args, **kwargs: Any) -> str:
177
+ """
178
+ Upload a Plotly Figure as a PNG image to an S3 bucket and generate a pre-signed URL.
179
+
180
+ Args:
181
+ fig (Figure): The Plotly Figure object to upload.
182
+ bucket_name (str): The name of the S3 bucket.
183
+ object_name (str): The name of the S3 object.
184
+
185
+ Keyword Args:
186
+ format_file (str): Format of the image. Defaults to 'png'.
187
+
188
+ Returns:
189
+ str: Pre-signed URL for the uploaded image.
190
+
191
+ Raises:
192
+ Exception: If there is an error uploading the image.
193
+ """
194
+ try:
195
+
196
+ if args:
197
+ bytes_data = args[0] if len(args) > 0 else None
198
+ object_name = args[1] if len(args) > 1 else None
199
+ else:
200
+ bytes_data = kwargs.get("bytes_data", None)
201
+ object_name = kwargs.get("object_name", None)
202
+
203
+ if bytes_data is None:
204
+ raise Exception("Figure is None")
205
+
206
+ if object_name is None:
207
+ raise Exception("Object name is None")
208
+
209
+ format_file : FormatFile = kwargs.get("format_file", "pdf")
210
+ mimetypes = "application/pdf"
211
+
212
+ if format_file not in ["png", "jpeg", "svg", "html", "pdf"]:
213
+ raise Exception("Invalid format_file provided. Supported formats are: png, jpeg, svg, html, pdf")
214
+ if format_file == "png":
215
+ mimetypes = "image/png"
216
+ elif format_file == "jpeg":
217
+ mimetypes = "image/jpeg"
218
+ elif format_file == "svg":
219
+ mimetypes = "image/svg+xml"
220
+ elif format_file == "html":
221
+ mimetypes = "text/html"
222
+ elif format_file == "pdf":
223
+ mimetypes = "application/pdf"
224
+ else:
225
+ raise Exception("Invalid MIME type provided")
226
+
227
+ s3_resource = self._get_s3_resource()
228
+
229
+ s3_resource.Bucket(self.bucket_name).Object(object_name).put(Body=bytes_data, ContentType=mimetypes)
230
+
231
+ except Exception as e:
232
+ logger.error(f"Error uploading image: {str(e)}")
233
+ raise Exception(f"Error uploading image: {str(e)}")
175
234
 
176
235
  def upload_image(self, *args, **kwargs: Any) -> str:
177
236
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyaws-s3
3
- Version: 1.0.20
3
+ Version: 1.0.22
4
4
  Summary: A Python package for AWS S3 utilities
5
5
  Author-email: Giuseppe Zileni <giuseppe.zileni@gmail.com>
6
6
  Keywords: aws,s3,utilities
@@ -9,49 +9,49 @@ Classifier: Operating System :: OS Independent
9
9
  Requires-Python: >=3.9
10
10
  Description-Content-Type: text/markdown
11
11
  License-File: LICENSE.md
12
- Requires-Dist: aioboto3==14.3.0
13
- Requires-Dist: aiobotocore==2.22.0
14
- Requires-Dist: aiofiles==24.1.0
15
- Requires-Dist: aiohappyeyeballs==2.6.1
16
- Requires-Dist: aiohttp==3.11.18
17
- Requires-Dist: aioitertools==0.12.0
18
- Requires-Dist: aiosignal==1.3.2
19
- Requires-Dist: attrs==25.3.0
20
- Requires-Dist: boto3==1.37.3
21
- Requires-Dist: botocore==1.37.3
22
- Requires-Dist: build==1.2.2.post1
23
- Requires-Dist: chardet==5.2.0
24
- Requires-Dist: contourpy==1.3.2
25
- Requires-Dist: cycler==0.12.1
26
- Requires-Dist: fonttools==4.58.0
27
- Requires-Dist: fpdf==1.7.2
28
- Requires-Dist: frozenlist==1.6.0
29
- Requires-Dist: idna==3.10
30
- Requires-Dist: iniconfig==2.1.0
31
- Requires-Dist: jmespath==1.0.1
32
- Requires-Dist: kiwisolver==1.4.8
33
- Requires-Dist: matplotlib==3.10.3
34
- Requires-Dist: multidict==6.4.3
35
- Requires-Dist: narwhals==1.39.1
12
+ Requires-Dist: aioboto3>=14.3.0
13
+ Requires-Dist: aiobotocore>=2.22.0
14
+ Requires-Dist: aiofiles>=24.1.0
15
+ Requires-Dist: aiohappyeyeballs>=2.6.1
16
+ Requires-Dist: aiohttp>=3.11.18
17
+ Requires-Dist: aioitertools>=0.12.0
18
+ Requires-Dist: aiosignal>=1.3.2
19
+ Requires-Dist: attrs>=25.3.0
20
+ Requires-Dist: boto3>=1.37.3
21
+ Requires-Dist: botocore>=1.37.3
22
+ Requires-Dist: build>=1.2.2.post1
23
+ Requires-Dist: chardet>=5.2.0
24
+ Requires-Dist: contourpy>=1.3.2
25
+ Requires-Dist: cycler>=0.12.1
26
+ Requires-Dist: fonttools>=4.58.0
27
+ Requires-Dist: fpdf>=1.7.2
28
+ Requires-Dist: frozenlist>=1.6.0
29
+ Requires-Dist: idna>=3.10
30
+ Requires-Dist: iniconfig>=2.1.0
31
+ Requires-Dist: jmespath>=1.0.1
32
+ Requires-Dist: kiwisolver>=1.4.8
33
+ Requires-Dist: matplotlib>=3.10.3
34
+ Requires-Dist: multidict>=6.4.3
35
+ Requires-Dist: narwhals>=1.39.1
36
36
  Requires-Dist: packaging>=23.2
37
- Requires-Dist: pandas==2.2.3
38
- Requires-Dist: pillow==11.2.1
39
- Requires-Dist: plotly==6.1.0
40
- Requires-Dist: pluggy==1.6.0
41
- Requires-Dist: propcache==0.3.1
42
- Requires-Dist: pyparsing==3.2.3
43
- Requires-Dist: pyproject_hooks==1.2.0
44
- Requires-Dist: pytest==8.3.5
45
- Requires-Dist: python-dateutil==2.9.0.post0
46
- Requires-Dist: pytz==2025.2
47
- Requires-Dist: reportlab==4.4.1
48
- Requires-Dist: s3transfer==0.11.3
49
- Requires-Dist: setuptools==80.7.1
50
- Requires-Dist: six==1.17.0
51
- Requires-Dist: tzdata==2025.2
52
- Requires-Dist: urllib3==2.4.0
53
- Requires-Dist: wrapt==1.17.2
54
- Requires-Dist: yarl==1.20.0
37
+ Requires-Dist: pandas>=2.2.3
38
+ Requires-Dist: pillow>=11.2.1
39
+ Requires-Dist: plotly>=6.1.0
40
+ Requires-Dist: pluggy>=1.6.0
41
+ Requires-Dist: propcache>=0.3.1
42
+ Requires-Dist: pyparsing>=3.2.3
43
+ Requires-Dist: pyproject_hooks>=1.2.0
44
+ Requires-Dist: pytest>=8.3.5
45
+ Requires-Dist: python-dateutil>=2.9.0.post0
46
+ Requires-Dist: pytz>=2025.2
47
+ Requires-Dist: reportlab>=4.4.1
48
+ Requires-Dist: s3transfer>=0.11.3
49
+ Requires-Dist: setuptools>=80.7.1
50
+ Requires-Dist: six>=1.17.0
51
+ Requires-Dist: tzdata>=2025.2
52
+ Requires-Dist: urllib3>=2.4.0
53
+ Requires-Dist: wrapt>=1.17.2
54
+ Requires-Dist: yarl>=1.20.0
55
55
  Dynamic: license-file
56
56
 
57
57
  # PYAWS_S3
@@ -0,0 +1,7 @@
1
+ pyaws_s3/__init__.py,sha256=Tr7xJiCKOMWYydOJ4kxHlA7AR1X3pRsJ8MjxJev2wsw,24
2
+ pyaws_s3/s3.py,sha256=TPQ88d9vWKIKw6ZwqvyM69VZjWTIPNddB8fs7hTVWaU,22654
3
+ pyaws_s3-1.0.22.dist-info/licenses/LICENSE.md,sha256=7WXohDebeZpcVn_nH2aIaLhFZRvZBdcPSqWsO12lhwM,1074
4
+ pyaws_s3-1.0.22.dist-info/METADATA,sha256=SnljXwsQWPP1OdYtL2msZb93o5fiE_cCshuYgq7ycJA,5464
5
+ pyaws_s3-1.0.22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ pyaws_s3-1.0.22.dist-info/top_level.txt,sha256=MxSSC4Q8Vr32wKgrUAlwT4BTXwqUaG_CAWoBuPeXYjQ,9
7
+ pyaws_s3-1.0.22.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- pyaws_s3/__init__.py,sha256=Tr7xJiCKOMWYydOJ4kxHlA7AR1X3pRsJ8MjxJev2wsw,24
2
- pyaws_s3/s3.py,sha256=ZuhqpK5uwL-0jxnKXoT-nil0QnzApNXxHUSyGypk1sc,20366
3
- pyaws_s3-1.0.20.dist-info/licenses/LICENSE.md,sha256=7WXohDebeZpcVn_nH2aIaLhFZRvZBdcPSqWsO12lhwM,1074
4
- pyaws_s3-1.0.20.dist-info/METADATA,sha256=EQOXhu-dDaxyyuw17_LhChqLdtcszxQWUzbkedm2bLc,5464
5
- pyaws_s3-1.0.20.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
- pyaws_s3-1.0.20.dist-info/top_level.txt,sha256=MxSSC4Q8Vr32wKgrUAlwT4BTXwqUaG_CAWoBuPeXYjQ,9
7
- pyaws_s3-1.0.20.dist-info/RECORD,,