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(
        "192.168.31.245:9000",
        access_key="ponponon",
        secret_key="ponponon"
    )

    # Make 'asiatrip' bucket if not exist.
    found = client.bucket_exists("whoisface")
    if not found:
        client.make_bucket("whoisface")
    else:
        print("Bucket 'whoisface' already exists")

    # Upload '/home/user/Photos/asiaphotos.zip' as object name
    # 'asiaphotos-2015.zip' to bucket 'asiatrip'.
    # client.fput_object(
    #     "asiatrip", "asiaphotos-2015.zip", "/home/user/Photos/asiaphotos.zip",
    # )
    # print(
    #     "'/home/user/Photos/asiaphotos.zip' is successfully uploaded as "
    #     "object 'asiaphotos-2015.zip' to bucket 'asiatrip'."
    # )


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

Error:

 File "/home/bot/.local/share/virtualenvs/ideaboom-3stdf9Mx/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='192.168.31.245', port=9000): Max retries exceeded with url: /whoisface?location= (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:997)')))

Solution:

 client = Minio(
    "192.168.31.245:9000",
    access_key="ponponon",
    secret_key="ponponon",
    secure=False
)

Plus if it is http, add secure=False


universe_king
3.4k 声望680 粉丝