Category Archives: S3

S3 copy

You cannot copy from remote to remote. You need to first copy locally and then copy to remote, or vice versa.

If you need to copy from local to s3 you need to setup public ACL then or add policy to allow public access to uploaded files.

https://gcore.com/docs/storage/manage-object-storage/configure-aws-sli-s3cmd-and-aws-javascript-sdk/configure-access-control-on-s3-storage-with-aws-cli-and-s3cmd

https://s3tools.org/s3cmd-sync

## You may choose to remove --recursive if is required only for the bucket or folder and not for objects within.
s3cmd setacl --acl-private --recursive s3://mybucket-name
s3cmd setacl --acl-private --recursive s3://mybucket-name/folder-name
s3cmd setacl --acl-private --recursive s3://mybucket-name/folder-name/object-name
s3cmd setacl --acl-public --recursive s3://mybucket-name
s3cmd setacl --acl-public --recursive s3://mybucket-name/folder-name
s3cmd setacl --acl-public --recursive s3://mybucket-name/folder-name/object-name

For example:

s3cmd sync --skip-existing . s3://sonic/rs/ -c ~/.s3cfg-digitalocean
s3cmd info s3://sonic/ -c ~/.s3cfg-digitalocean
s3cmd setpolicy ~/polisa.json s3://sonic/ -c ~/.s3cfg-digitalocean
s3cmd setpolicy ~/polisa.json s3://sonic/ -c ~/.s3cfg-digitalocean
s3cmd sync --skip-existing s3://leaflets/rs/ ./

cat ~/polisa.json
{"Id":"PublicSharePolicy","Version":"2012-10-17","Statement":[{"Action":["s3:*"],"Effect":"Allow","Resource":["arn:aws:s3:::sonic","arn:aws:s3:::sonic/*"],"Principal":"*"}]}