Name | s3lite JSON |
Version |
0.1.8
JSON |
| download |
home_page | None |
Summary | Minimal async s3 implementation. |
upload_time | 2024-08-18 14:04:32 |
maintainer | None |
docs_url | None |
author | RuslanUC |
requires_python | <4.0,>=3.9 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# S3Lite
Minimal async s3 client implementation in python.
# Installation
**Requirements:**
- Python 3.9+
```bash
pip install s3lite
```
# Examples
### List buckets
```python
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
```python
from s3lite import Client
client = Client("key-id", "secret-key", "https://s3-endpoint")
bucket = await client.create_bucket("new-bucket")
```
### Upload object
```python
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
```python
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
```python
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
```python
from s3lite import Client
client = Client("key-id", "secret-key", "https://s3-endpoint")
saved_path = await client.delete_object("new-bucket", "test-image.jpg")
```
Raw data
{
"_id": null,
"home_page": null,
"name": "s3lite",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "RuslanUC",
"author_email": "dev_ruslan_uc@protonmail.com",
"download_url": "https://files.pythonhosted.org/packages/b0/0c/c42278bf87721f9b75454f356ca7a7b72b33e82f639ea47d596c2cdd5bbe/s3lite-0.1.8.tar.gz",
"platform": null,
"description": "# S3Lite\nMinimal async s3 client implementation in python.\n\n# Installation\n**Requirements:**\n - Python 3.9+\n\n```bash\npip install s3lite\n```\n\n# Examples\n\n### List buckets\n```python\nfrom s3lite import Client\n\nclient = Client(\"key-id\", \"secret-key\", \"https://s3-endpoint\")\nfor bucket in await client.ls_buckets():\n print(bucket.name)\n```\n\n### Create new bucket\n```python\nfrom s3lite import Client\n\nclient = Client(\"key-id\", \"secret-key\", \"https://s3-endpoint\")\nbucket = await client.create_bucket(\"new-bucket\")\n```\n\n### Upload object\n```python\nfrom io import BytesIO\nfrom s3lite import Client\n\nclient = Client(\"key-id\", \"secret-key\", \"https://s3-endpoint\")\nobject_from_path = await client.upload_object(\"new-bucket\", \"test-image.jpg\", \"./local-image.png\")\n\nwith open(\"document.txt\", \"rb\") as f: # Make sure to open file in read-binary mode\n object_from_file = await client.upload_object(\"new-bucket\", \"document.txt\", f)\n\nbytes_io = BytesIO(b\"test file content\")\nobject_from_bytesio = await client.upload_object(\"new-bucket\", \"test.txt\", bytes_io)\n```\n\n### Download object\n```python\nfrom s3lite import Client\n\nclient = Client(\"key-id\", \"secret-key\", \"https://s3-endpoint\")\nsaved_path = await client.download_object(\"new-bucket\", \"test-image.jpg\", \"./local-image.png\")\n\nbytes_io = await client.download_object(\"new-bucket\", \"document.txt\", in_memory=True)\n\npartial_bytes = await client.download_object(\"new-bucket\", \"test.txt\", in_memory=True, offset=4, limit=6)\n```\n\n### Generate presigned url\n```python\nfrom s3lite import Client\n\nclient = Client(\"key-id\", \"secret-key\", \"https://s3-endpoint\")\n\nobj = await client.upload_object(\"new-bucket\", \"test-image.jpg\", \"./local-image.png\")\npresigned_url = obj.share() # Url will be valid for 1 day\n\npresigned_url_1h = client.share(\"new-bucket\", \"test.txt\", 3600) # Url will be valid for 1 hour\n```\n\n### Delete object\n```python\nfrom s3lite import Client\n\nclient = Client(\"key-id\", \"secret-key\", \"https://s3-endpoint\")\nsaved_path = await client.delete_object(\"new-bucket\", \"test-image.jpg\")\n```",
"bugtrack_url": null,
"license": null,
"summary": "Minimal async s3 implementation.",
"version": "0.1.8",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ce0b5f236e2f2c7bf8f1ee7ec2292c3fdf4a8c33451ee8dad84e3f4402b93e62",
"md5": "f96d533851ce50719c06e0ff3f6a5532",
"sha256": "a4994fdeea4544330b5a1ddcdb6b91242233da99c5dc6d806c50a71119a6faa8"
},
"downloads": -1,
"filename": "s3lite-0.1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f96d533851ce50719c06e0ff3f6a5532",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 10289,
"upload_time": "2024-08-18T14:04:31",
"upload_time_iso_8601": "2024-08-18T14:04:31.236114Z",
"url": "https://files.pythonhosted.org/packages/ce/0b/5f236e2f2c7bf8f1ee7ec2292c3fdf4a8c33451ee8dad84e3f4402b93e62/s3lite-0.1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b00cc42278bf87721f9b75454f356ca7a7b72b33e82f639ea47d596c2cdd5bbe",
"md5": "df9b03ff988012806db750259cb69345",
"sha256": "f158f49d8c05b4e730f3ea6f4b971af251c61ebcb5df4a9a361aeeb9b577772c"
},
"downloads": -1,
"filename": "s3lite-0.1.8.tar.gz",
"has_sig": false,
"md5_digest": "df9b03ff988012806db750259cb69345",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 8666,
"upload_time": "2024-08-18T14:04:32",
"upload_time_iso_8601": "2024-08-18T14:04:32.973741Z",
"url": "https://files.pythonhosted.org/packages/b0/0c/c42278bf87721f9b75454f356ca7a7b72b33e82f639ea47d596c2cdd5bbe/s3lite-0.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-18 14:04:32",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "s3lite"
}