s3lite


Names3lite JSON
Version 0.1.4 PyPI version JSON
download
home_page
SummaryMinimal async s3 implementation.
upload_time2024-03-11 10:28:33
maintainer
docs_urlNone
authorRuslanUC
requires_python>=3.9,<4.0
license
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": "",
    "name": "s3lite",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "RuslanUC",
    "author_email": "dev_ruslan_uc@protonmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c6/69/71605af9228e14597abc6426a1402222ad2dc74ea0a88d2085506a81f330/s3lite-0.1.4.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": "",
    "summary": "Minimal async s3 implementation.",
    "version": "0.1.4",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f58f3f31a06d6b22caf5b7b1ac741b9d0535600d466c1398ffb8c297420449e4",
                "md5": "6791ae1c546570860e0d43a4063922d0",
                "sha256": "c9a7bd78f6fc4a8d18f6b63e2b00292eb25a20155b4c524d11621deb045c2bcd"
            },
            "downloads": -1,
            "filename": "s3lite-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6791ae1c546570860e0d43a4063922d0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 9568,
            "upload_time": "2024-03-11T10:28:31",
            "upload_time_iso_8601": "2024-03-11T10:28:31.493664Z",
            "url": "https://files.pythonhosted.org/packages/f5/8f/3f31a06d6b22caf5b7b1ac741b9d0535600d466c1398ffb8c297420449e4/s3lite-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c66971605af9228e14597abc6426a1402222ad2dc74ea0a88d2085506a81f330",
                "md5": "604186f9e028333114deace520ae3762",
                "sha256": "04de2fb28828059c0309660528c504e9475fc4f3f754baaceadcfd21ca27bd93"
            },
            "downloads": -1,
            "filename": "s3lite-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "604186f9e028333114deace520ae3762",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 8028,
            "upload_time": "2024-03-11T10:28:33",
            "upload_time_iso_8601": "2024-03-11T10:28:33.844962Z",
            "url": "https://files.pythonhosted.org/packages/c6/69/71605af9228e14597abc6426a1402222ad2dc74ea0a88d2085506a81f330/s3lite-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-11 10:28:33",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "s3lite"
}
        
Elapsed time: 0.55250s