add script for making all files in a bucket public

This commit is contained in:
Jakub Sokołowski 2018-08-30 14:43:28 -04:00
parent 81a59dd20a
commit 09014e92a2
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 25 additions and 0 deletions

25
s3utils/make_public.py Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env python3
import os
import boto3
import botocore
bucket_name = 'status-im'
session = boto3.session.Session()
s3 = boto3.resource(
's3',
region_name='ams3',
endpoint_url='https://ams3.digitaloceanspaces.com',
aws_access_key_id=os.environ['DO_ID'],
aws_secret_access_key=os.environ['DO_SECRET']
)
bucket = s3.Bucket(bucket_name)
for obj in bucket.objects.all():
if obj.key == 'index.html':
continue
rval = obj.Acl().put(ACL='public-read')
result = rval['ResponseMetadata']['HTTPStatusCode']
print('{:<30} - {}'.format(obj.key, result))