Zurück zum Ranking

MinIO Client SDK for Python

miniominio-clientsdkaws-s3s3-bucket
Sterne-Wachstum
Sterne
1.1k
Forks
370
Wochenwachstum
Issues
2
5001k
Jan. 2023März 2024Mai 2025Juli 2026
ArtefaktePyPIpip install minio-py
README

MinIO Python Client SDK for Amazon S3 Compatible Cloud Storage Slack Apache V2 License

The MinIO Python Client SDK provides high level APIs to access any MinIO Object Storage or other Amazon S3 compatible service.

This Quickstart Guide covers how to install the MinIO client SDK, connect to the object storage service, and create a sample file uploader.

The example below uses:

The play server is a public MinIO cluster located at https://play.min.io. This cluster runs the latest stable version of MinIO and may be used for testing and development. The access credentials in the example are open to the public and all data uploaded to play should be considered public and world-readable.

For a complete list of APIs and examples, see the Python SDK Documentation

Install the MinIO Python SDK

The Python SDK requires Python version 3.10+. You can install the SDK with pip or from the minio/minio-py GitHub repository:

Using pip

pip3 install minio

Using Source From GitHub

git clone https://github.com/minio/minio-py
cd minio-py
python setup.py install

Create a MinIO Client

To connect to the target service, create a MinIO client using the Minio() method with the following required parameters:

Parameter Description
endpoint URL of the target service.
access_key Access key (user ID) of a user account in the service.
secret_key Secret key (password) for the user account.

For example:

from minio import Minio

client = Minio(
    endpoint="play.min.io",
    access_key="Q3AM3UQ867SPQQA43P2F",
    secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
)

Example - File Uploader

This example does the following:

  • Connects to the MinIO play server using the provided credentials.
  • Creates a bucket named python-test-bucket if it does not already exist.
  • Uploads a file named test-file.txt from /tmp, renaming it my-test-file.txt.
  • Verifies the file was created using mc ls.

file_uploader.py

# file_uploader.py MinIO Python SDK example
from minio import Minio
from minio.error import S3Error

def main():
    # Create a client with the MinIO server playground, its access key
    # and secret key.
    client = Minio(
        endpoint="play.min.io",
        access_key="Q3AM3UQ867SPQQA43P2F",
        secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
    )

    # The file to upload, change this path if needed
    source_file = "/tmp/test-file.txt"

    # The destination bucket and filename on the MinIO server
    bucket_name = "python-test-bucket"
    destination_file = "my-test-file.txt"
    
    # Make the bucket if it doesn't exist.
    found = client.bucket_exists(bucket_name=bucket_name)
    if not found:
        client.make_bucket(bucket_name=bucket_name)
        print("Created bucket", bucket_name)
    else:
        print("Bucket", bucket_name, "already exists")

    # Upload the file, renaming it in the process
    client.fput_object(
        bucket_name=bucket_name,
        object_name=destination_file,
        file_path=source_file,
    )
    print(
        source_file, "successfully uploaded as object",
        destination_file, "to bucket", bucket_name,
    )

if __name__ == "__main__":
    try:
        main()
    except S3Error as exc:
        print("error occurred.", exc)

To run this example:

  1. Create a file in /tmp named test-file.txt. To use a different path or filename, modify the value of source_file.

  2. Run file_uploader.py with the following command:

python file_uploader.py

If the bucket does not exist on the server, the output resembles the following:

Created bucket python-test-bucket
/tmp/test-file.txt successfully uploaded as object my-test-file.txt to bucket python-test-bucket
  1. Verify the uploaded file with mc ls:
mc ls play/python-test-bucket
[2023-11-03 22:18:54 UTC]  20KiB STANDARD my-test-file.txt

RDMA / GPUDirect Storage (optional)

put_object and get_object can dispatch to MinIO's RDMA + GPUDirect Storage path via minio-cpp. It is strictly opt-in and the SDK stays pure-Python unless used.

from minio import Minio

client = Minio(
    endpoint="server:9000",
    access_key="...",
    secret_key="...",
    secure=False,
    enable_rdma=True,             # opt-in
)

buf = bytearray(1 << 20)
client.put_object(
    bucket_name="b", object_name="o",
    data=buf, length=len(buf),    # buffer-protocol object selects RDMA
)

dst = bytearray(1 << 20)
n = client.get_object(
    bucket_name="b", object_name="o",
    into=dst, length=len(dst),    # into= selects RDMA, returns bytes
)

Requires libminiocpp.so (built with -DMINIO_CPP_ENABLE_RDMA=ON) on the host's library search path (or pointed at via the MINIOCPP_LIB env var). GPU buffer pointers (e.g. CuPy's arr.data.ptr, PyTorch's t.data_ptr()) work as data= / into= arguments unchanged — pass them as int.

See examples/put_object_rdma.py and examples/get_object_rdma.py.

More References

Explore Further

Contribute

Contributors Guide

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE and NOTICE for more information.

PYPI

Ähnliche Repositories
rustfs/rustfs

🚀2.3x faster than MinIO for 4KB object payloads. RustFS is an open-source, S3-compatible high-performance object storage system supporting migration and coexistence with other S3-compatible platforms such as MinIO and Ceph.

Rustcrates.ioApache License 2.0bigdatacloud-native
rustfs.com/download/
30.1k1.3k
labring/laf

Laf is a vibrant cloud development platform that provides essential tools like cloud functions, databases, and storage solutions. It enables developers to quickly unleash their creativity and bring innovative ideas to life with ease.

TypeScriptnpmApache License 2.0serverlessfirebase
sealos.run
7.6k671
linhaojun857/aurora

基于SpringBoot+Vue开发的个人博客系统

JavaMavenApache License 2.0springbootvue
linhaojun.top
4.6k733
hwholiday/learning_tools

Go 学习、Go 进阶、Go 实用工具类、Go DDD 项目落地、Go-kit 、Go-Micro 、Go 推送平台、微服务实践

GoGo ModulesApache License 2.0rpc-grpcgin
hwholiday.com
4.3k725
gee1k/uPic

📤uPic is a native, powerful, beautiful and simple picture and file upload tool for macOS.

SwiftApache License 2.0swiftmacos-app
blog.svend.cc/upic
3.7k265
minio/minio-go

MinIO Go client SDK for S3 compatible object storage

GoGo ModulesApache License 2.0librariesgo
docs.min.io/docs/golang-client-quickstart-guide.html
3k744
yzcheng90/x-springboot

X-SpringBoot是一个轻量级的Java快速开发平台,基于springboot3和jdk21,使用虚拟线程,可配置的SaaS功能具备RBAC功能、自动代码生成、多种存储系统,多种短信平台,可开放api授权。代码简洁,架构清晰,能快速开发项目并交付【接私活利器】

JavaMavenspring-bootspring-mvc
2.7k820
yzcheng90/X-SpringBoot

X-SpringBoot是一个轻量级的Java快速开发平台,能快速开发项目并交付【接私活利器】

JavaMavenspring-bootspring-mvc
2.4k757
dromara/x-file-storage

一行代码将文件存储到 本地、FTP、SFTP、WebDAV、谷歌云存储、阿里云OSS、华为云OBS、七牛云Kodo、腾讯云COS、百度云 BOS、又拍云USS、MinIO、 AWS S3、FastDFS、 Azure Blob Storage、金山云 KS3、美团云 MSS、京东云 OSS、天翼云 OOS、移动云 EOS、沃云 OSS、 网易数帆 NOS、Ucloud US3、青云 QingStor、平安云 OBS、首云 OSS、IBM COS、其它兼容 S3 协议的平台。后续即将支持 Samba、NFS

JavaMavenApache License 2.0file-storagefile-upload
x-file-storage.xuyanwu.cn
2.2k328
notea-org/notea

📒 Self hosted note taking app stored on S3

TypeScriptnpmminiodocker
2.1k375
sambecker/exif-photo-blog

Photo blog, reporting 🤓 EXIF camera details (aperture, shutter speed, ISO) for each image.

TypeScriptnpmapprouterexif
photos.sambecker.com
1.7k387
haydenbleasel/files-sdk

A unified storage SDK for object and blob backends. One small, honest API. Web-standards I/O.

TypeScriptnpmMIT Licenseblobcloudflare
files-sdk.dev
1.5k40