Yandex-S3
Asyncio compatible SDK for Yandex Object Storage inspired by aioaws.
This library does not depend on boto, boto3 or any of the other bloated, opaque and mind thumbing AWS SDKs. Instead, it is written from scratch to provide clean, secure and easily debuggable access to AWS services I want to use.
It currently supports:
- S3 - list, delete, recursive delete, generating signed upload URLs, generating signed download URLs
- AWS Signature Version 4
authentication for any AWS service (this is the only clean & modern implementation of AWS4 I know of in python, see
core.py)
The only dependencies of yandex-s3, are:
- aiofiles - for asynchronous reading of files
- cryptography - for verifying SNS signatures
- httpx - for HTTP requests
- pydantic - for validating responses
Install
pip install yandex-s3
S3 Usage
import asyncio
# requires `pip install yandex-s3`
from s3 import S3Client
# requires `pip install devtools`
from devtools import debug
async def s3_demo():
s3 = S3Client(
access_key='<access key>',
secret_key='<secret key>',
region='<region>',
s3_bucket='test-bucket'
)
# upload a file:
await s3.upload('dir/subdir/dummy.txt', b'Dummy')
# list all files in a bucket
files = [f async for f in s3.list()]
debug(files)
"""
[
S3File(
key='dir/subdir/dummy.txt',
last_modified=datetime.datetime(...),
size=5,
e_tag='...',
storage_class='STANDARD',
),
] (list) len=1
"""
# list all files with a given prefix in a bucket
files = [f async for f in s3.list('dir/subdir/')]
debug(files)
# # delete a file
# await s3.delete('dir/subdir/dummy.txt')
# # delete two files
# await s3.delete('dir/subdir/file1.txt', 'dir/subdir/file2.txt')
# delete recursively based on a prefix
await s3.delete_recursive('dir/subdir')
# generate an upload link suitable for sending to a borwser to enabled
# secure direct file upload (see below)
upload_data = s3.signed_upload_url(
path='dir/subdir',
filename='dummy.txt',
content_type='text/plain',
size=123,
)
debug(upload_data)
"""
{
'url': 'https://test-bucket.storage.yandexcloud.net/',
'fields': {
'Key': 'dir/subdir/dummy.txt',
'Content-Type': 'text/plain',
'AWSAccessKeyId': '...',
'Content-Disposition': 'attachment; filename="dummy.txt"',
'Policy': ('...'),
'Signature': '...',
},
} (dict) len=2
"""
# generate a temporary link to allow yourself or a client to download a file
download_url = s3.signed_download_url('dir/subdir/dummy.txt', max_age=60)
print(download_url)
#> https://test-bucket.storage.yandexcloud.net/dir/subdir/dummy.txt?AWSAccessKeyId=...&Signature=...&Expires=...
# download file
content = await s3.download('dir/subdir/dummy.txt')
print(content)
#> b'Dummy'
async def main():
await s3_demo()
asyncio.run(main())
Metadata
Release files for yandex-s3 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| yandex-s3-0.1.1.tar.gz | 11.6 kB | Without provenance | Details for yandex-s3-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yandex_s3-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for yandex_s3-0.1.1-py3-none-any.whl |
Total release size: 23.4 kB
Release files / yandex-s3-0.1.1.tar.gz
| Download URL | yandex-s3-0.1.1.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e0ae19c61a0fde40d9b7487812e4328fe28ee92ac97014c09678007872e8feb
|
|
BLAKE2b-256 checksum How to use checksums |
78eaf1b5b6d9bb01e6874ad22db2b0017759865deb0ed6f4db8266bb73ac7454
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
|
Release files / yandex_s3-0.1.1-py3-none-any.whl
| Download URL | yandex_s3-0.1.1-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
baf4ca5f20a68b16eea7c346a244c4eff1ec18e8951b632147efd9348eba33ce
|
|
BLAKE2b-256 checksum How to use checksums |
95c1f0e15d0dc3891284bcdcc3cd2150114b6816dcc3629a3e9188da0a75217c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
|
Security for yandex-s3 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.