Skip to content

Commit

Permalink
Add init description to README
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua committed Sep 23, 2024
1 parent 87aec3d commit d09b5a0
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,38 @@ $ pip install tosfs
* Init via `ak/sk`

```python

from tosfs.core import TosFileSystem
from tos import StaticCredentialsProvider

tosfs = TosFileSystem(
key='ak',
secret='sk',
endpoint_url='http://tos-cn-beijing.volces.com',
region='cn-beijing',
credentials_provider=StaticCredentialsProvider, # optional
)
```

* Init via system env
*



make sure these envs take effect:

```shell
export TOS_ACCESS_KEY=' your ak here '
export TOS_SECRET_KEY=' your sk here '
export TOS_ENDPOINT='http://tos-cn-beijing.volces.com'
export TOS_REGION='cn-beijing'
```
then init `TosFileSystem` by setting `credentials_provider` to `EnvCredentialsProvider`

```python
import os
from tosfs.core import TosFileSystem
from tos import EnvCredentialsProvider

tosfs = TosFileSystem(
endpoint_url=os.environ.get("TOS_ENDPOINT"),
region=os.environ.get("TOS_REGION"),
credentials_provider=EnvCredentialsProvider, # must
)
```

0 comments on commit d09b5a0

Please sign in to comment.