diff options
author | Alex <alex@adnab.me> | 2023-01-02 12:48:52 +0000 |
---|---|---|
committer | Alex <alex@adnab.me> | 2023-01-02 12:48:52 +0000 |
commit | 822e344845436c13437c30362e2ffd8fb29077d8 (patch) | |
tree | 3d6293ec77d0799c5559368c9156951cbce80dc2 | |
parent | 7f7d53cfa991054afcd2940cc43a4d7f1a6668e7 (diff) | |
parent | 0c7ed0b0af40c3521b9dc259a98f8aad05999b4f (diff) | |
download | garage-822e344845436c13437c30362e2ffd8fb29077d8.tar.gz garage-822e344845436c13437c30362e2ffd8fb29077d8.zip |
Merge pull request 'Add some docs about using Python Minio SDK' (#455) from kaiyou/garage:docs-s3-libs into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/455
-rw-r--r-- | doc/book/build/python.md | 59 |
1 files changed, 51 insertions, 8 deletions
diff --git a/doc/book/build/python.md b/doc/book/build/python.md index 19912e85..5b797897 100644 --- a/doc/book/build/python.md +++ b/doc/book/build/python.md @@ -5,16 +5,59 @@ weight = 20 ## S3 -*Coming soon* +### Using Minio SDK + +First install the SDK: + +```bash +pip3 install minio +``` + +Then instantiate a client object using garage root domain, api key and secret: + +```python +import minio + +client = minio.Minio( + "your.domain.tld", + "GKyourapikey", + "abcd[...]1234", + # Force the region, this is specific to garage + region="region", +) +``` -Some refs: - - Minio SDK - - [Reference](https://docs.min.io/docs/python-client-api-reference.html) +Then use all the standard S3 endpoints as implemented by the Minio SDK: + +``` +# List buckets +print(client.list_buckets()) + +# Put an object containing 'content' to /path in bucket named 'bucket': +content = b"content" +client.put_object( + "bucket", + "path", + io.BytesIO(content), + len(content), +) + +# Read the object back and check contents +data = client.get_object("bucket", "path").read() +assert data == content +``` + +For further documentation, see the Minio SDK +[Reference](https://docs.min.io/docs/python-client-api-reference.html) + +### Using Amazon boto3 + +*Coming soon* - - Amazon boto3 - - [Installation](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html) - - [Reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html) - - [Example](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-uploading-files.html) +See the official documentation: + - [Installation](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html) + - [Reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html) + - [Example](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-uploading-files.html) ## K2V |