minio


Nameminio JSON
Version 7.2.10 PyPI version JSON
download
home_pagehttps://github.com/minio/minio-py
SummaryMinIO Python SDK for Amazon S3 Compatible Cloud Storage
upload_time2024-10-24 20:23:56
maintainerNone
docs_urlNone
authorMinIO, Inc.
requires_python>3.8
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MinIO Python Client SDK for Amazon S3 Compatible Cloud Storage [![Slack](https://slack.min.io/slack?type=svg)](https://slack.min.io) [![Apache V2 License](https://img.shields.io/badge/license-Apache%20V2-blue.svg)](https://github.com/minio/minio-py/blob/master/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:
- [Python version 3.7+](https://www.python.org/downloads/) 
- The [MinIO `mc` command line tool](https://min.io/docs/minio/linux/reference/minio-mc.html)
- The MinIO `play` test server

The `play` server is a public MinIO cluster located at [https://play.min.io](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 Client API Reference](https://min.io/docs/minio/linux/developers/python/API.html)

## Install the MinIO Python SDK

The Python SDK requires Python version 3.7+.
You can install the SDK with `pip` or from the [`minio/minio-py` GitHub repository](https://github.com/minio/minio-py):

### Using `pip`

```sh
pip3 install minio
```

### Using Source From GitHub

```sh
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:

```py
from minio import Minio

client = Minio("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`](https://min.io/docs/minio/linux/reference/minio-mc/mc-ls.html).

### `file_uploader.py`

```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("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)
    if not found:
        client.make_bucket(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, destination_file, 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:

```sh
python file_uploader.py
```

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

```sh
Created bucket python-test-bucket
/tmp/test-file.txt successfully uploaded as object my-test-file.txt to bucket python-test-bucket
```

3. Verify the uploaded file with `mc ls`:

```sh
mc ls play/python-test-bucket
[2023-11-03 22:18:54 UTC]  20KiB STANDARD my-test-file.txt
```

## More References

* [Python Client API Reference](https://min.io/docs/minio/linux/developers/python/API.html)
* [Examples](https://github.com/minio/minio-py/tree/master/examples)

## Explore Further

* [Complete Documentation](https://min.io/docs/minio/kubernetes/upstream/index.html)

## Contribute

[Contributors Guide](https://github.com/minio/minio-py/blob/master/CONTRIBUTING.md)

## License

This SDK is distributed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0), see [LICENSE](https://github.com/minio/minio-py/blob/master/LICENSE) and [NOTICE](https://github.com/minio/minio-go/blob/master/NOTICE) for more information.

[![PYPI](https://img.shields.io/pypi/v/minio.svg)](https://pypi.python.org/pypi/minio)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/minio/minio-py",
    "name": "minio",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "MinIO, Inc.",
    "author_email": "dev@min.io",
    "download_url": "https://files.pythonhosted.org/packages/84/d8/04b4c8ceaa7bae49a674ccdba53530599e73fb3c6a8f8cf8e26ee0eb390d/minio-7.2.10.tar.gz",
    "platform": null,
    "description": "# MinIO Python Client SDK for Amazon S3 Compatible Cloud Storage [![Slack](https://slack.min.io/slack?type=svg)](https://slack.min.io) [![Apache V2 License](https://img.shields.io/badge/license-Apache%20V2-blue.svg)](https://github.com/minio/minio-py/blob/master/LICENSE)\n\nThe MinIO Python Client SDK provides high level APIs to access any MinIO Object Storage or other Amazon S3 compatible service.\n\nThis Quickstart Guide covers how to install the MinIO client SDK, connect to the object storage service, and create a sample file uploader.\n\nThe example below uses:\n- [Python version 3.7+](https://www.python.org/downloads/) \n- The [MinIO `mc` command line tool](https://min.io/docs/minio/linux/reference/minio-mc.html)\n- The MinIO `play` test server\n\nThe `play` server is a public MinIO cluster located at [https://play.min.io](https://play.min.io).\nThis cluster runs the latest stable version of MinIO and may be used for testing and development.\nThe access credentials in the example are open to the public and all data uploaded to `play` should be considered public and world-readable.\n\nFor a complete list of APIs and examples, see the [Python Client API Reference](https://min.io/docs/minio/linux/developers/python/API.html)\n\n## Install the MinIO Python SDK\n\nThe Python SDK requires Python version 3.7+.\nYou can install the SDK with `pip` or from the [`minio/minio-py` GitHub repository](https://github.com/minio/minio-py):\n\n### Using `pip`\n\n```sh\npip3 install minio\n```\n\n### Using Source From GitHub\n\n```sh\ngit clone https://github.com/minio/minio-py\ncd minio-py\npython setup.py install\n```\n\n## Create a MinIO Client\n\nTo connect to the target service, create a MinIO client using the `Minio()` method with the following required parameters:\n\n| Parameter    | Description                                            |\n|--------------|--------------------------------------------------------|\n| `endpoint`   | URL of the target service.                             |\n| `access_key` | Access key (user ID) of a user account in the service. |\n| `secret_key` | Secret key (password) for the user account.            |\n\nFor example:\n\n```py\nfrom minio import Minio\n\nclient = Minio(\"play.min.io\",\n    access_key=\"Q3AM3UQ867SPQQA43P2F\",\n    secret_key=\"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG\",\n)\n```\n\n## Example - File Uploader\n\nThis example does the following:\n\n- Connects to the MinIO `play` server using the provided credentials.\n- Creates a bucket named `python-test-bucket` if it does not already exist.\n- Uploads a file named `test-file.txt` from `/tmp`, renaming it `my-test-file.txt`.\n- Verifies the file was created using [`mc ls`](https://min.io/docs/minio/linux/reference/minio-mc/mc-ls.html).\n\n### `file_uploader.py`\n\n```py\n# file_uploader.py MinIO Python SDK example\nfrom minio import Minio\nfrom minio.error import S3Error\n\ndef main():\n    # Create a client with the MinIO server playground, its access key\n    # and secret key.\n    client = Minio(\"play.min.io\",\n        access_key=\"Q3AM3UQ867SPQQA43P2F\",\n        secret_key=\"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG\",\n    )\n\n    # The file to upload, change this path if needed\n    source_file = \"/tmp/test-file.txt\"\n\n    # The destination bucket and filename on the MinIO server\n    bucket_name = \"python-test-bucket\"\n    destination_file = \"my-test-file.txt\"\n    \n    # Make the bucket if it doesn't exist.\n    found = client.bucket_exists(bucket_name)\n    if not found:\n        client.make_bucket(bucket_name)\n        print(\"Created bucket\", bucket_name)\n    else:\n        print(\"Bucket\", bucket_name, \"already exists\")\n\n    # Upload the file, renaming it in the process\n    client.fput_object(\n        bucket_name, destination_file, source_file,\n    )\n    print(\n        source_file, \"successfully uploaded as object\",\n        destination_file, \"to bucket\", bucket_name,\n    )\n\nif __name__ == \"__main__\":\n    try:\n        main()\n    except S3Error as exc:\n        print(\"error occurred.\", exc)\n```\n\nTo run this example:\n\n1. Create a file in `/tmp` named `test-file.txt`.\n   To use a different path or filename, modify the value of `source_file`.\n\n2. Run `file_uploader.py` with the following command:\n\n```sh\npython file_uploader.py\n```\n\nIf the bucket does not exist on the server, the output resembles the following:\n\n```sh\nCreated bucket python-test-bucket\n/tmp/test-file.txt successfully uploaded as object my-test-file.txt to bucket python-test-bucket\n```\n\n3. Verify the uploaded file with `mc ls`:\n\n```sh\nmc ls play/python-test-bucket\n[2023-11-03 22:18:54 UTC]  20KiB STANDARD my-test-file.txt\n```\n\n## More References\n\n* [Python Client API Reference](https://min.io/docs/minio/linux/developers/python/API.html)\n* [Examples](https://github.com/minio/minio-py/tree/master/examples)\n\n## Explore Further\n\n* [Complete Documentation](https://min.io/docs/minio/kubernetes/upstream/index.html)\n\n## Contribute\n\n[Contributors Guide](https://github.com/minio/minio-py/blob/master/CONTRIBUTING.md)\n\n## License\n\nThis SDK is distributed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0), see [LICENSE](https://github.com/minio/minio-py/blob/master/LICENSE) and [NOTICE](https://github.com/minio/minio-go/blob/master/NOTICE) for more information.\n\n[![PYPI](https://img.shields.io/pypi/v/minio.svg)](https://pypi.python.org/pypi/minio)\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "MinIO Python SDK for Amazon S3 Compatible Cloud Storage",
    "version": "7.2.10",
    "project_urls": {
        "Download": "https://github.com/minio/minio-py/releases",
        "Homepage": "https://github.com/minio/minio-py"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "206f1b1f5025bf43c2a4ca8112332db586c8077048ec8bcea2deb269eac84577",
                "md5": "126a26015a306d6f7d4227b20db10967",
                "sha256": "5961c58192b1d70d3a2a362064b8e027b8232688998a6d1251dadbb02ab57a7d"
            },
            "downloads": -1,
            "filename": "minio-7.2.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "126a26015a306d6f7d4227b20db10967",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">3.8",
            "size": 93943,
            "upload_time": "2024-10-24T20:23:55",
            "upload_time_iso_8601": "2024-10-24T20:23:55.490412Z",
            "url": "https://files.pythonhosted.org/packages/20/6f/1b1f5025bf43c2a4ca8112332db586c8077048ec8bcea2deb269eac84577/minio-7.2.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "84d804b4c8ceaa7bae49a674ccdba53530599e73fb3c6a8f8cf8e26ee0eb390d",
                "md5": "53a02b0624c83bc1d71bc61eefdf8d23",
                "sha256": "418c31ac79346a580df04a0e14db1becbc548a6e7cca61f9bc4ef3bcd336c449"
            },
            "downloads": -1,
            "filename": "minio-7.2.10.tar.gz",
            "has_sig": false,
            "md5_digest": "53a02b0624c83bc1d71bc61eefdf8d23",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">3.8",
            "size": 135388,
            "upload_time": "2024-10-24T20:23:56",
            "upload_time_iso_8601": "2024-10-24T20:23:56.795860Z",
            "url": "https://files.pythonhosted.org/packages/84/d8/04b4c8ceaa7bae49a674ccdba53530599e73fb3c6a8f8cf8e26ee0eb390d/minio-7.2.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-24 20:23:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "minio",
    "github_project": "minio-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "minio"
}
        
Elapsed time: 1.07292s