MinIO Python Library for Amazon S3 Compatible Cloud Storage for Python
Project description
MinIO Python Library for Amazon S3 Compatible Cloud Storage
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.
Minimum Requirements
- Python 2.7 or higher
Download from pip
pip install minio
Download from pip3
pip3 install minio
Download from source
git clone https://github.com/minio/minio-py
cd minio-py
python setup.py install
Initialize MinIO Client
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.min.io',
access_key='Q3AM3UQ867SPQQA43P2F',
secret_key='zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG',
secure=True)
Quick Start Example - File Uploader
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.min.io in this example. Feel free to use this service for testing and development. Access credentials shown in this example are open to the public.
file-uploader.py
# 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.min.io',
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
# 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)
Run file-uploader
python file_uploader.py
mc ls play/maylogs/
[2016-05-27 16:41:37 PDT] 12MiB pumaserver_debug.log
API Reference
The full API Reference is available here.
API Reference : Bucket Operations
make_bucket
list_buckets
bucket_exists
remove_bucket
list_objects
list_objects_v2
list_incomplete_uploads
API Reference : Bucket policy Operations
API Reference : Bucket notification Operations
set_bucket_notification
get_bucket_notification
remove_all_bucket_notification
listen_bucket_notification
API Reference : File Object Operations
API Reference : Object Operations
get_object
put_object
stat_object
copy_object
get_partial_object
remove_object
remove_objects
remove_incomplete_upload
API Reference : Presigned Operations
Full Examples
Full Examples : Bucket Operations
- make_bucket.py
- list_buckets.py
- bucket_exists.py
- list_objects.py
- remove_bucket.py
- list_incomplete_uploads.py
Full Examples : Bucket policy Operations
Full Examples: Bucket notification Operations
- set_bucket_notification.py
- get_bucket_notification.py
- remove_all_bucket_notification.py
- listen_bucket_notification.py
Full Examples : File Object Operations
Full Examples : Object Operations
- get_object.py
- put_object.py
- stat_object.py
- copy_object.py
- get_partial_object.py
- remove_object.py
- remove_objects.py
- remove_incomplete_upload.py
Full Examples : Presigned Operations
Explore Further
Contribute
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ak-minio-5.0.6.post1.macosx-10.14-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8527ad66ee527c63c4b1e0667e471d0c49210038d66b7cde8daf2f1d4e1c0ac4 |
|
MD5 | c335661a10a540fde45bba519d0222db |
|
BLAKE2b-256 | ef1b4cc63aede6ef83d3681378b93f21ed75cbd93d1b106b06551e28df66887d |
Hashes for ak_minio-5.0.6.post1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c20d28ba68981e9714cac7c17c5f9c13fb89ed75fc748aa8f7d8cd3e51e28324 |
|
MD5 | ca22d643cd34633aa59f4a6ca696f96c |
|
BLAKE2b-256 | 701baa66595bbd8e9052ab460dfcd0b56530a42ab30674dc1b4ddf3a4ced24d0 |