Python SDK QuickStart
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 SDK Reference section.
This document assumes that you have a working Python setup in place.

Minimum Requirements

  • Python 2.7 or higher

Download from pip

1
pip install minio
Copied!

Download from pip3

1
pip3 install minio
Copied!

Initialize OSS Client

You need four items in order to connect to OSS service.
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.
1
from minio import Minio
2
from minio.error import ResponseError
3
4
minioClient = Minio('storage-4175974314028753.cloud.bigconnect.io',
5
access_key='Q3AM3UQ867SPQQA43P2F',
6
secret_key='zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG',
7
secure=True)
Copied!
NOTE on concurrent usage: The Minio object is thread safe when using the Python threading library. Specifically, it is NOT safe to share it between multiple processes, for example when using multiprocessing.Pool. The solution is simply to create a new Minio object in each process, and not share it between processes.

Quick Start Example - File Uploader

This example program connects to a OSS Service, makes a bucket on the server and then uploads a file to the bucket.
file-uploader.py
1
Copy# Import MinIO library.
2
from minio import Minio
3
from minio.error import (ResponseError, BucketAlreadyOwnedByYou,
4
BucketAlreadyExists)
5
6
# Initialize minioClient with an endpoint and access/secret keys.
7
minioClient = Minio('storage-4175974314028753.cloud.bigconnect.io',
8
access_key='Q3AM3UQ867SPQQA43P2F',
9
secret_key='zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG',
10
secure=True)
11
12
# Make a bucket with the make_bucket API call.
13
try:
14
minioClient.make_bucket("maylogs", location="us-east-1")
15
except BucketAlreadyOwnedByYou as err:
16
pass
17
except BucketAlreadyExists as err:
18
pass
19
except ResponseError as err:
20
raise
21
22
# Put an object 'pumaserver_debug.log' with contents from 'pumaserver_debug.log'.
23
try:
24
minioClient.fput_object('maylogs', 'pumaserver_debug.log', '/tmp/pumaserver_debug.log')
25
except ResponseError as err:
26
print(err)
27
Copied!
Run file-uploader
1
Copypython file_uploader.py
2
3
osscli ls play/maylogs/
4
[2016-05-27 16:41:37 PDT] 12MiB pumaserver_debug.log
Copied!
Have a look at the Python SDK Reference for more information.
Last modified 1yr ago