METADATA 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. Metadata-Version: 2.1
  2. Name: minio
  3. Version: 7.2.20
  4. Summary: MinIO Python SDK for Amazon S3 Compatible Cloud Storage
  5. Home-page: https://github.com/minio/minio-py
  6. Download-URL: https://github.com/minio/minio-py/releases
  7. Author: MinIO, Inc.
  8. Author-email: dev@min.io
  9. License: Apache-2.0
  10. Classifier: Development Status :: 5 - Production/Stable
  11. Classifier: Intended Audience :: Developers
  12. Classifier: License :: OSI Approved :: Apache Software License
  13. Classifier: Natural Language :: English
  14. Classifier: Operating System :: OS Independent
  15. Classifier: Programming Language :: Python
  16. Classifier: Programming Language :: Python :: 3.9
  17. Classifier: Programming Language :: Python :: 3.10
  18. Classifier: Programming Language :: Python :: 3.11
  19. Classifier: Programming Language :: Python :: 3.12
  20. Classifier: Programming Language :: Python :: 3.13
  21. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  22. Requires-Python: >=3.9
  23. Description-Content-Type: text/markdown
  24. License-File: LICENSE
  25. License-File: NOTICE
  26. Requires-Dist: argon2-cffi
  27. Requires-Dist: certifi
  28. Requires-Dist: pycryptodome
  29. Requires-Dist: typing-extensions
  30. Requires-Dist: urllib3
  31. # 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)
  32. The MinIO Python Client SDK provides high level APIs to access any MinIO Object Storage or other Amazon S3 compatible service.
  33. This Quickstart Guide covers how to install the MinIO client SDK, connect to the object storage service, and create a sample file uploader.
  34. The example below uses:
  35. - [Python version 3.7+](https://www.python.org/downloads/)
  36. - The [MinIO `mc` command line tool](https://min.io/docs/minio/linux/reference/minio-mc.html)
  37. - The MinIO `play` test server
  38. The `play` server is a public MinIO cluster located at [https://play.min.io](https://play.min.io).
  39. This cluster runs the latest stable version of MinIO and may be used for testing and development.
  40. The access credentials in the example are open to the public and all data uploaded to `play` should be considered public and world-readable.
  41. For a complete list of APIs and examples, see the [Python Client API Reference](https://min.io/docs/minio/linux/developers/python/API.html)
  42. ## Install the MinIO Python SDK
  43. The Python SDK requires Python version 3.7+.
  44. You can install the SDK with `pip` or from the [`minio/minio-py` GitHub repository](https://github.com/minio/minio-py):
  45. ### Using `pip`
  46. ```sh
  47. pip3 install minio
  48. ```
  49. ### Using Source From GitHub
  50. ```sh
  51. git clone https://github.com/minio/minio-py
  52. cd minio-py
  53. python setup.py install
  54. ```
  55. ## Create a MinIO Client
  56. To connect to the target service, create a MinIO client using the `Minio()` method with the following required parameters:
  57. | Parameter | Description |
  58. |--------------|--------------------------------------------------------|
  59. | `endpoint` | URL of the target service. |
  60. | `access_key` | Access key (user ID) of a user account in the service. |
  61. | `secret_key` | Secret key (password) for the user account. |
  62. For example:
  63. ```py
  64. from minio import Minio
  65. client = Minio("play.min.io",
  66. access_key="Q3AM3UQ867SPQQA43P2F",
  67. secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
  68. )
  69. ```
  70. ## Example - File Uploader
  71. This example does the following:
  72. - Connects to the MinIO `play` server using the provided credentials.
  73. - Creates a bucket named `python-test-bucket` if it does not already exist.
  74. - Uploads a file named `test-file.txt` from `/tmp`, renaming it `my-test-file.txt`.
  75. - Verifies the file was created using [`mc ls`](https://min.io/docs/minio/linux/reference/minio-mc/mc-ls.html).
  76. ### `file_uploader.py`
  77. ```py
  78. # file_uploader.py MinIO Python SDK example
  79. from minio import Minio
  80. from minio.error import S3Error
  81. def main():
  82. # Create a client with the MinIO server playground, its access key
  83. # and secret key.
  84. client = Minio("play.min.io",
  85. access_key="Q3AM3UQ867SPQQA43P2F",
  86. secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
  87. )
  88. # The file to upload, change this path if needed
  89. source_file = "/tmp/test-file.txt"
  90. # The destination bucket and filename on the MinIO server
  91. bucket_name = "python-test-bucket"
  92. destination_file = "my-test-file.txt"
  93. # Make the bucket if it doesn't exist.
  94. found = client.bucket_exists(bucket_name)
  95. if not found:
  96. client.make_bucket(bucket_name)
  97. print("Created bucket", bucket_name)
  98. else:
  99. print("Bucket", bucket_name, "already exists")
  100. # Upload the file, renaming it in the process
  101. client.fput_object(
  102. bucket_name, destination_file, source_file,
  103. )
  104. print(
  105. source_file, "successfully uploaded as object",
  106. destination_file, "to bucket", bucket_name,
  107. )
  108. if __name__ == "__main__":
  109. try:
  110. main()
  111. except S3Error as exc:
  112. print("error occurred.", exc)
  113. ```
  114. To run this example:
  115. 1. Create a file in `/tmp` named `test-file.txt`.
  116. To use a different path or filename, modify the value of `source_file`.
  117. 2. Run `file_uploader.py` with the following command:
  118. ```sh
  119. python file_uploader.py
  120. ```
  121. If the bucket does not exist on the server, the output resembles the following:
  122. ```sh
  123. Created bucket python-test-bucket
  124. /tmp/test-file.txt successfully uploaded as object my-test-file.txt to bucket python-test-bucket
  125. ```
  126. 3. Verify the uploaded file with `mc ls`:
  127. ```sh
  128. mc ls play/python-test-bucket
  129. [2023-11-03 22:18:54 UTC] 20KiB STANDARD my-test-file.txt
  130. ```
  131. ## More References
  132. * [Python Client API Reference](https://min.io/docs/minio/linux/developers/python/API.html)
  133. * [Examples](https://github.com/minio/minio-py/tree/master/examples)
  134. ## Explore Further
  135. * [Complete Documentation](https://min.io/docs/minio/kubernetes/upstream/index.html)
  136. ## Contribute
  137. [Contributors Guide](https://github.com/minio/minio-py/blob/master/CONTRIBUTING.md)
  138. ## License
  139. 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.
  140. [![PYPI](https://img.shields.io/pypi/v/minio.svg)](https://pypi.python.org/pypi/minio)