Skip to main content

Minimal async s3 implementation.

Project description

S3Lite

Minimal async s3 client implementation in python.

Installation

Requirements:

  • Python 3.9+
pip install s3lite

Examples

List buckets

from s3lite import Client

client = Client("key-id", "secret-key", "https://s3-endpoint")
for bucket in await client.ls_buckets():
    print(bucket.name)

Create new bucket

from s3lite import Client

client = Client("key-id", "secret-key", "https://s3-endpoint")
bucket = await client.create_bucket("new-bucket")

Upload object

from io import BytesIO
from s3lite import Client

client = Client("key-id", "secret-key", "https://s3-endpoint")
object_from_path = await client.upload_object("new-bucket", "test-image.jpg", "./local-image.png")

with open("document.txt", "rb") as f:  # Make sure to open file in read-binary mode
    object_from_file = await client.upload_object("new-bucket", "document.txt", f)

bytes_io = BytesIO(b"test file content")
object_from_bytesio = await client.upload_object("new-bucket", "test.txt", bytes_io)

Download object

from s3lite import Client

client = Client("key-id", "secret-key", "https://s3-endpoint")
saved_path = await client.download_object("new-bucket", "test-image.jpg", "./local-image.png")

bytes_io = await client.download_object("new-bucket", "document.txt", in_memory=True)

partial_bytes = await client.download_object("new-bucket", "test.txt", in_memory=True, offset=4, limit=6)

Generate presigned url

from s3lite import Client

client = Client("key-id", "secret-key", "https://s3-endpoint")

obj = await client.upload_object("new-bucket", "test-image.jpg", "./local-image.png")
presigned_url = obj.share()  # Url will be valid for 1 day

presigned_url_1h = client.share("new-bucket", "test.txt", 3600)  # Url will be valid for 1 hour

Delete object

from s3lite import Client

client = Client("key-id", "secret-key", "https://s3-endpoint")
saved_path = await client.delete_object("new-bucket", "test-image.jpg")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

s3lite-0.1.8.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

s3lite-0.1.8-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file s3lite-0.1.8.tar.gz.

File metadata

  • Download URL: s3lite-0.1.8.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.8 Linux/6.6.4-100.fc38.x86_64

File hashes

Hashes for s3lite-0.1.8.tar.gz
Algorithm Hash digest
SHA256 f158f49d8c05b4e730f3ea6f4b971af251c61ebcb5df4a9a361aeeb9b577772c
MD5 df9b03ff988012806db750259cb69345
BLAKE2b-256 b00cc42278bf87721f9b75454f356ca7a7b72b33e82f639ea47d596c2cdd5bbe

See more details on using hashes here.

File details

Details for the file s3lite-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: s3lite-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.8 Linux/6.6.4-100.fc38.x86_64

File hashes

Hashes for s3lite-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a4994fdeea4544330b5a1ddcdb6b91242233da99c5dc6d806c50a71119a6faa8
MD5 f96d533851ce50719c06e0ff3f6a5532
BLAKE2b-256 ce0b5f236e2f2c7bf8f1ee7ec2292c3fdf4a8c33451ee8dad84e3f4402b93e62

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page