tos


Nametos JSON
Version 2.6.8 PyPI version JSON
download
home_pagehttps://www.volcengine.com/
SummaryVolc TOS (Tinder Object Storage) SDK
upload_time2024-02-20 07:44:11
maintainer
docs_urlNone
authorsunyushan
requires_python
license
keywords boilerplate
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Volcengine TOS SDK for Python
The TOS Python SDK enables Python developers to easily work with TOS(Tinder Object Storage) service in the volcengine.
This document will show developers some basic examples about TOS bucket and object operation.


## Install
### Requirements
- Python3
# Quick Start

This section introduces how to create a bucket, upload/download/delete an object in TOS service through our SDK.

## Create a TOS Client

You can interact with TOS service after initiating a TOSClient instance.
The accesskey and secretkey of your account, endpoint and region are required as params.

```python
import tos

ak = "your access key"
sk = "your secret key"
endpoint = "your endpoint"
region = "your region"
bucket_name = "your bucket name"
object_key = "your object key"
client = tos.TosClientV2(ak, sk, endpoint, region)     
```

## Create a bucket

The bucket is a kind of unique namespace in TOS, which is a container to store data.
This example shows you how to create a bucket.

```python
import tos

ak = "your access key"
sk = "your secret key"
endpoint = "your endpoint"
region = "your region"
bucket_name = "your bucket name"
client = tos.TosClientV2(ak, sk, endpoint, region)
client.create_bucket(bucket_name)                            
```

## Put Object

You can put your file as an object into your own bucket.

```python
# call put_object to upload you data to the TOS                     
client.put_object(bucket_name, object_key, content="123")
assert resp.status == 200       
```
## Get Object
You can download objects in the TOS bucket through our SDK.

```python
# call get_object to download your data from your bucket
client.get_object(bucket_name, object_key)
```

## Delete Object

Your can delete your objects in the bucket:

```python
# call put_object to upload you data to the TOS  
resp = client.put_object(bucket_name, key_name, content="123")
assert resp.status_code == 200   
# call delete_object to delete an object in your bucket
resp = client.delete_object(bucket_name, key_name)
assert resp.status_code == 204
```

## License
[Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html)

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.volcengine.com/",
    "name": "tos",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "boilerplate",
    "author": "sunyushan",
    "author_email": "sunyushan.jason@bytedance.com",
    "download_url": "https://files.pythonhosted.org/packages/ca/2c/8a11fc3f2f9fd9df0e23e4f160640f0916dbf19414409a038455582bf02b/tos-2.6.8.tar.gz",
    "platform": null,
    "description": "\n# Volcengine TOS SDK for Python\nThe TOS Python SDK enables Python developers to easily work with TOS(Tinder Object Storage) service in the volcengine.\nThis document will show developers some basic examples about TOS bucket and object operation.\n\n\n## Install\n### Requirements\n- Python3\n# Quick Start\n\nThis section introduces how to create a bucket, upload/download/delete an object in TOS service through our SDK.\n\n## Create a TOS Client\n\nYou can interact with TOS service after initiating a TOSClient instance.\nThe accesskey and secretkey of your account, endpoint and region are required as params.\n\n```python\nimport tos\n\nak = \"your access key\"\nsk = \"your secret key\"\nendpoint = \"your endpoint\"\nregion = \"your region\"\nbucket_name = \"your bucket name\"\nobject_key = \"your object key\"\nclient = tos.TosClientV2(ak, sk, endpoint, region)     \n```\n\n## Create a bucket\n\nThe bucket is a kind of unique namespace in TOS, which is a container to store data.\nThis example shows you how to create a bucket.\n\n```python\nimport tos\n\nak = \"your access key\"\nsk = \"your secret key\"\nendpoint = \"your endpoint\"\nregion = \"your region\"\nbucket_name = \"your bucket name\"\nclient = tos.TosClientV2(ak, sk, endpoint, region)\nclient.create_bucket(bucket_name)                            \n```\n\n## Put Object\n\nYou can put your file as an object into your own bucket.\n\n```python\n# call put_object to upload you data to the TOS                     \nclient.put_object(bucket_name, object_key, content=\"123\")\nassert resp.status == 200       \n```\n## Get Object\nYou can download objects in the TOS bucket through our SDK.\n\n```python\n# call get_object to download your data from your bucket\nclient.get_object(bucket_name, object_key)\n```\n\n## Delete Object\n\nYour can delete your objects in the bucket\uff1a\n\n```python\n# call put_object to upload you data to the TOS  \nresp = client.put_object(bucket_name, key_name, content=\"123\")\nassert resp.status_code == 200   \n# call delete_object to delete an object in your bucket\nresp = client.delete_object(bucket_name, key_name)\nassert resp.status_code == 204\n```\n\n## License\n[Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html)\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Volc TOS (Tinder Object Storage) SDK",
    "version": "2.6.8",
    "project_urls": {
        "Homepage": "https://www.volcengine.com/"
    },
    "split_keywords": [
        "boilerplate"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ca2c8a11fc3f2f9fd9df0e23e4f160640f0916dbf19414409a038455582bf02b",
                "md5": "d3b9cac169c59b488535c077d21aef74",
                "sha256": "6a2b79d4ca1697b6e5da3bc399adc2464574b0827b8291e2d08bc3d6d79a8d0d"
            },
            "downloads": -1,
            "filename": "tos-2.6.8.tar.gz",
            "has_sig": false,
            "md5_digest": "d3b9cac169c59b488535c077d21aef74",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 111311,
            "upload_time": "2024-02-20T07:44:11",
            "upload_time_iso_8601": "2024-02-20T07:44:11.843595Z",
            "url": "https://files.pythonhosted.org/packages/ca/2c/8a11fc3f2f9fd9df0e23e4f160640f0916dbf19414409a038455582bf02b/tos-2.6.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-20 07:44:11",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "tos"
}
        
Elapsed time: 0.18408s