updater.py 852 B

123456789101112131415161718192021222324252627282930313233343536
  1. from minio import Minio
  2. from minio.error import S3Error
  3. # Source code imported from https://docs.min.io/docs/python-client-quickstart-guide.html
  4. def main():
  5. # Create a client with the MinIO server playground, its access key
  6. # and secret key.
  7. client = Minio(
  8. "172.17.0.2:9000",
  9. access_key="minio",
  10. secret_key="miniokey",
  11. secure=False,
  12. )
  13. # Make bucket if not exist.
  14. found = client.bucket_exists("my-bucket")
  15. if not found:
  16. client.make_bucket("my-bucket")
  17. else:
  18. print("Bucket 'my-bucket' already exists")
  19. # Upload
  20. client.fput_object(
  21. "my-bucket", "hello.txt", "./test/data/hello.txt",
  22. )
  23. print("Success")
  24. if __name__ == "__main__":
  25. try:
  26. main()
  27. except S3Error as exc:
  28. print("error occurred.", exc)