-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-object-info-by-etag.py
More file actions
46 lines (30 loc) · 1.17 KB
/
get-object-info-by-etag.py
File metadata and controls
46 lines (30 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# coding: utf-8
from __future__ import absolute_import
import argparse
import boto3
from idb import config
argparser = argparse.ArgumentParser(description='Script to check an s3 object by etag')
argparser.add_argument("-b", "--bucket", required=True, help="Name of s3 bucket. Example: idigbio-images-prod")
argparser.add_argument("-e", "--etag", required=True, help="etag of the object")
args = argparser.parse_args()
bucket = args.bucket
etag = args.etag
#bucket = 'idigbio-images-prod'
#etag = 'fc778eb00cae12784a5328e5ac1df2e1'
PUBLIC_READ = {u'Grantee': {u'Type': 'Group',
u'URI': 'http://acs.amazonaws.com/groups/global/AllUsers'},
u'Permission': 'READ'}
def s3connection():
return boto3.resource(
's3',
aws_access_key_id=config.IDB_STORAGE_ACCESS_KEY,
aws_secret_access_key=config.IDB_STORAGE_SECRET_KEY,
endpoint_url="https://s.idigbio.org")
conn = s3connection()
k = conn.Object(bucket, etag)
k.load()
def check_pub(k):
return PUBLIC_READ in k.Acl().grants
print ("MIME type of " + etag + " is '" + k.content_type + "'")
print ("checking existence of PUBLIC acl...")
print (check_pub(k))