I want to send an image in an s3 storage (MinIO).
Here is an example code :
import cv2
import argparse
import boto3
from botocore.client import Config
import logging
logging.basicConfig(level=logging.INFO)
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('--s3_endpoint', type=str, default='http://127.0.0.1:9000')
parser.add_argument('--s3_access_key', type=str,default='minioadmin')
parser.add_argument('--s3_secret_key', type=str,default='minioadmin')
parser.add_argument('--image_bucket', type=str,default='my_bucket')
args = parser.parse_args()
s3 = boto3.client(
"s3",
use_ssl=False,
endpoint_url=args.s3_endpoint,
aws_access_key_id=args.s3_access_key,
aws_secret_access_key=args.s3_secret_key,
region_name='us-east-1',
config=Config(s3={'addressing_style': 'path'})
)
def upload_image_s3(bucket, image_name, image):
logging.info("Uploading image "+image_name+" to s3 bucket "+bucket)
body = cv2.imencode('.jpg', image)[1].tostring()
s3.put_object(Bucket=bucket, Key = image_name, Body = body)
logging.info("Image uploaded !")
upload_image_s3(args.processed_images_bucket,'test/image.jpg',cv2.imread("resources/images/my_image.jpg"))
But when I run it, I get stuck on the put_object() call forever (well, until timeout to be exact).
To do my test, I run locally a minIO server using the default configuration (on Windows).
Have you any idea what is the problem in my case ?