Skip to content

Commit 810d929

Browse files
author
Duc Anh
committed
allow custom s3-equivalent storage service
1 parent 235ac93 commit 810d929

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

inbox/util/blockstore.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
STORE_MSG_ON_S3 = config.get('STORE_MESSAGES_ON_S3', None)
1212

1313
if STORE_MSG_ON_S3:
14-
from boto.s3.connection import S3Connection
14+
from boto.s3.connection import S3Connection, OrdinaryCallingFormat
1515
from boto.s3.key import Key
1616
else:
1717
from inbox.util.file import mkdirp
@@ -56,8 +56,13 @@ def _save_to_s3_bucket(data_sha256, bucket_name, data):
5656
start = time.time()
5757

5858
# Boto pools connections at the class level
59-
conn = S3Connection(config.get('AWS_ACCESS_KEY_ID'),
60-
config.get('AWS_SECRET_ACCESS_KEY'))
59+
conn = S3Connection(host=config.get('CUSTOM_S3_HOST', None),
60+
port=config.get('CUSTOM_S3_PORT', None),
61+
is_secure=config.get('CUSTOM_S3_SSL', True)
62+
aws_access_key_id=config.get('AWS_ACCESS_KEY_ID'),
63+
aws_secret_access_key=config.get('AWS_SECRET_ACCESS_KEY'),
64+
calling_format=OrdinaryCallingFormat())
65+
6166
bucket = conn.get_bucket(bucket_name, validate=False)
6267

6368
# See if it already exists; if so, don't recreate.
@@ -117,8 +122,13 @@ def _get_from_s3_bucket(data_sha256, bucket_name):
117122
if not data_sha256:
118123
return None
119124

120-
conn = S3Connection(config.get('AWS_ACCESS_KEY_ID'),
121-
config.get('AWS_SECRET_ACCESS_KEY'))
125+
conn = S3Connection(host=config.get('CUSTOM_S3_HOST', None),
126+
port=config.get('CUSTOM_S3_PORT', None),
127+
is_secure=config.get('CUSTOM_S3_SSL', True)
128+
aws_access_key_id=config.get('AWS_ACCESS_KEY_ID'),
129+
aws_secret_access_key=config.get('AWS_SECRET_ACCESS_KEY'),
130+
calling_format=OrdinaryCallingFormat())
131+
122132
bucket = conn.get_bucket(bucket_name, validate=False)
123133

124134
key = bucket.get_key(data_sha256)

0 commit comments

Comments
 (0)