Home > Back-end >  copy object from minio bucket to S3 bucket
copy object from minio bucket to S3 bucket

Time:12-01

I'm trying to use native boto3 to copy objects from Minio bucket to aws s3 bucket. I have seen that the protocol is exactly the same but the problem with the buckets endpoint. I know it can be possible through mc client but i want to use native boto3 client. I have set both source and destination buckets to be public but i still can't get it done. here is a sample code

import boto3

SESSION_s3 = boto3.session.Session(region_name="MY_REGION")
s3 = SESSION_s3.resource('s3', aws_access_key_id='MY_ACCESS_KEY',aws_secret_access_key='MY_SECRET_KEY').meta.client

SESSION_minio = boto3.session.Session(region_name="MY_REGION")
config=boto3.session.Config(signature_version='s3v4')
minio = SESSION_minio.resource('s3', endpoint_url='http://my_minio_public_server:9000',
                       aws_access_key_id='username',
                       aws_secret_access_key='password', config=config
                       ).meta.client

src = {"Bucket": "minio_bucket", "Key": "example.jpg"}
s3.copy(src, "s3_bucket_name", "example.jpg", SourceClient=minio) 

that leads to the below error

botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the CopyObject operation: Access Denied

Is there anyway to get this connectivity between the two clients ? or is there any better idea ? noting that the minio client is not an option for me.

CodePudding user response:

The copy() command tells Amazon S3 to copy an object within the Amazon S3 ecosystem. It can be used to copy objects within the same bucket, or between buckets, even if those buckets are in different Regions.

However, minio exists 'outside' of Amazon S3. It doesn't know how to talk to Amazon S3 and S3 doesn't know how to talk to minio. They use their own sets of credentials that the other system doesn't recognise either. There is no interaction between the two systems.

Bottom line: You'll need to download the files from one system and upload them to the other.

  • Related