pyaws-s3 1.0.1__py3-none-any.whl → 1.0.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyaws_s3
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: A Python package for AWS S3 utilities
5
5
  Author: Giuseppe Zileni
6
6
  Author-email: Giuseppe Zileni <giuseppe.zileni@gmail.com>
@@ -52,7 +52,7 @@ Dynamic: requires-python
52
52
 
53
53
  ## Description
54
54
 
55
- `S3Client` is a Python class that simplifies interaction with AWS S3 for uploading, managing, and deleting files. It supports uploading images, DataFrames, PDFs, and generating pre-signed URLs.
55
+ `S3Client` is a Python class that simplifies interaction with AWS S3 for uploading, downloading, managing, and deleting files. It supports uploading images, DataFrames, PDFs, generating pre-signed URLs, downloading files, listing files, and deleting individual files.
56
56
 
57
57
  ## Installation
58
58
 
@@ -62,16 +62,16 @@ Make sure you have installed:
62
62
  pip install pyaws_s3
63
63
  ```
64
64
 
65
- ### Env Variabiles
65
+ ### Env Variables
66
66
 
67
- Make sure to add this environment variable:
67
+ Make sure to add these environment variables:
68
68
 
69
69
  ```bash
70
70
  AWS_ACCESS_KEY_ID=<Your Access Key Id>
71
- AWS_SECRET_ACCESS_KEY=<Your Secrect Access Key>
71
+ AWS_SECRET_ACCESS_KEY=<Your Secret Access Key>
72
72
  AWS_REGION=<Your Region>
73
73
  AWS_BUCKET_NAME=<Your Bucket Name>
74
- ```bash
74
+ ```
75
75
 
76
76
  ## Usage
77
77
 
@@ -125,6 +125,52 @@ import asyncio
125
125
  await s3.delete_all(filter="your_filter")
126
126
  ```
127
127
 
128
+ #### 5. `download(object_name, local_path=None, stream=False)`
129
+
130
+ Downloads a file from the S3 bucket.
131
+
132
+ - `object_name` (str): The name of the S3 object to download.
133
+ - `local_path` (str, optional): Local path to save the downloaded file. Required if `stream` is False.
134
+ - `stream` (bool, optional): If True, returns the file content as bytes instead of saving locally.
135
+
136
+ **Examples:**
137
+
138
+ Download and save locally:
139
+
140
+ ```python
141
+ local_path = s3.download("folder/image.svg", local_path="downloads/image.svg")
142
+ ```
143
+
144
+ Download as bytes (stream):
145
+
146
+ ```python
147
+ file_bytes = s3.download("folder/image.svg", stream=True)
148
+ ```
149
+
150
+ #### 6. `list_files(filter=None) -> list[str]`
151
+
152
+ Lists all files in the S3 bucket, optionally filtered by a substring.
153
+
154
+ - `filter` (str, optional): Only files containing this substring will be listed.
155
+
156
+ **Example:**
157
+
158
+ ```python
159
+ files = s3.list_files(filter="folder/")
160
+ ```
161
+
162
+ #### 7. `delete_file(object_name)`
163
+
164
+ Deletes a single file from the S3 bucket.
165
+
166
+ - `object_name` (str): The name of the S3 object to delete.
167
+
168
+ **Example:**
169
+
170
+ ```python
171
+ s3.delete_file("folder/image.svg")
172
+ ```
173
+
128
174
  ## Notes
129
175
 
130
176
  - All upload methods return a pre-signed URL for downloading the file.
@@ -146,4 +192,13 @@ s3 = S3Client(bucket_name="my-bucket")
146
192
  img_url = s3.upload_image(fig, "test.svg")
147
193
  df_url = s3.upload_from_dataframe(df, "mydata")
148
194
  pdf_url = s3.upload_to_pdf("Hello PDF", "hello.pdf")
195
+
196
+ # Download a file
197
+ local_path = s3.download("test.svg", local_path="downloads/test.svg")
198
+
199
+ # List files
200
+ files = s3.list_files()
201
+
202
+ # Delete a file
203
+ s3.delete_file("test.svg")
149
204
  ```
@@ -0,0 +1,4 @@
1
+ pyaws_s3-1.0.2.dist-info/METADATA,sha256=AoMP7svciEiYRWpaF16y3yml_5J-TjdAah2BqB7U0h4,5261
2
+ pyaws_s3-1.0.2.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
3
+ pyaws_s3-1.0.2.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
+ pyaws_s3-1.0.2.dist-info/RECORD,,
@@ -1,4 +0,0 @@
1
- pyaws_s3-1.0.1.dist-info/METADATA,sha256=Ge4YAe5dhTIncFBbgVRo7riwORP79SChW_04OermkF4,3940
2
- pyaws_s3-1.0.1.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
3
- pyaws_s3-1.0.1.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
- pyaws_s3-1.0.1.dist-info/RECORD,,