The Minio Python Client SDK provides simple APIs to access any Amazon S3 compatible object storage server.
This quickstart guide will show you how to install the client SDK and execute an example python program. For a complete list of APIs and examples, please take a look at the Python Client API Reference documentation.
This document assumes that you have a working Python setup in place.
- Python 2.7 or higher
pip install minio
pip3 install minio
git clone https://github.com/minio/minio-py
cd minio-py
python setup.py install
You need four items in order to connect to Minio object storage server.
Params | Description |
---|---|
endpoint | URL to object storage service. |
access_key | Access key is like user ID that uniquely identifies your account. |
secret_key | Secret key is the password to your account. |
secure | Set this value to 'True' to enable secure (HTTPS) access. |
from minio import Minio
from minio.error import ResponseError
minioClient = Minio('play.minio.io:9000',
access_key='Q3AM3UQ867SPQQA43P2F',
secret_key='zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG',
secure=True)
This example program connects to a Minio object storage server, makes a bucket on the server and then uploads a file to the bucket.
We will use the Minio server running at https://play.minio.io:9000 in this example. Feel free to use this service for testing and development. Access credentials shown in this example are open to the public.
# Import Minio library.
from minio import Minio
from minio.error import (ResponseError, BucketAlreadyOwnedByYou,
BucketAlreadyExists)
# Initialize minioClient with an endpoint and access/secret keys.
minioClient = Minio('play.minio.io:9000',
access_key='Q3AM3UQ867SPQQA43P2F',
secret_key='zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG',
secure=True)
# Make a bucket with the make_bucket API call.
try:
minioClient.make_bucket("maylogs", location="us-east-1")
except BucketAlreadyOwnedByYou as err:
pass
except BucketAlreadyExists as err:
pass
except ResponseError as err:
raise
else:
# Put an object 'pumaserver_debug.log' with contents from 'pumaserver_debug.log'.
try:
minioClient.fput_object('maylogs', 'pumaserver_debug.log', '/tmp/pumaserver_debug.log')
except ResponseError as err:
print(err)
python file_uploader.py
mc ls play/maylogs/
[2016-05-27 16:41:37 PDT] 12MiB pumaserver_debug.log
The full API Reference is available here.
make_bucket
list_buckets
bucket_exists
remove_bucket
list_objects
list_objects_v2
list_incomplete_uploads
set_bucket_notification
get_bucket_notification
remove_all_bucket_notification
listen_bucket_notification
get_object
put_object
stat_object
copy_object
get_partial_object
remove_object
remove_objects
remove_incomplete_upload
- make_bucket.py
- list_buckets.py
- bucket_exists.py
- list_objects.py
- remove_bucket.py
- list_incomplete_uploads.py
- set_bucket_notification.py
- get_bucket_notification.py
- remove_all_bucket_notification.py
- listen_bucket_notification.py