Python library to read S3 file as local file.
Project description
s3-reader
Python library to read S3 file as local file.
Requirement
- Python >=3.9
Installation
$ pip install s3-reader
Usage
from s3_reader import File
def check_s3_file(path):
file = File(path)
with open(file.path) as f:
...
check_s3_file('s3://<bucket>/path/to/file')
In this example, the S3 file is downloaded when file = File(path) is
executed, and it is stored as a temporary file.
file.path refers to the path of the locally stored temporary file.
At the end of the check_s3_file function, the file object is deleted, and
consequently, the temporary file is also deleted.
If path refers to a local file instead of an S3 file, File simply copies the path, and you can use the File object in the same manner.
You can pass following parameters to File constructor to setup AWS credential:
profile_name : str | None
AWS profile name.
aws_access_key_id : str | None
AWS access key id.
aws_secret_access_key : str | None
AWS secret access key.
aws_session_token : str | None
AWS session token.
region_name : str | None
AWS region name.
role_arn : str | None
AWS role arn for Assume role. If this is set, aws_access_key_id,
aws_secret_access_key, aws_session_token are replaced by Assume role.
session_name : str
AWS session name. Default is "s3_reader".
retry_mode : str
Retry mode for failed requests. Default is "standard".
max_attempts : int
Maximum number of retry attempts for failed requests. Default is 10.
use_device_code : bool
Whether to use device code flow for SSO login. Default is False.
max_trials : int
Maximum number of trials to retry after retrieving credential error.
Default is 10.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file s3_reader-0.4.0.tar.gz.
File metadata
- Download URL: s3_reader-0.4.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f6e62515260570c8c55d8e9ef2831d6af1f1e2e1c77a83f92d02c8f4daa9c5b
|
|
| MD5 |
07ce405d5be65383be8361ff19c4efdd
|
|
| BLAKE2b-256 |
0f6b6fee1d7ceeeb9f345bb88bef898944e86f4ccf59758134c141d241dae0bf
|
File details
Details for the file s3_reader-0.4.0-py3-none-any.whl.
File metadata
- Download URL: s3_reader-0.4.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39319f6f05f57c5c82d4e0c2433c8385321791eabe462cf143679367915faecb
|
|
| MD5 |
29abf76df2afb291d0a3d964045c4559
|
|
| BLAKE2b-256 |
eadb48fdf6db5f57a6f6417967af4c7ae17bcbd08b939c933b79c9807c775832
|