7
7
8
8
import os
9
9
10
+ from .base import BaseBucket
11
+
10
12
try :
11
13
from boto .s3 import connect_to_region , connection
12
14
from boto .exception import S3ResponseError
15
+ from boto .s3 .connection import ProtocolIndependentOrdinaryCallingFormat
13
16
except ImportError :
14
17
from warnings import warn
15
18
install_modules = [
@@ -33,12 +36,14 @@ def __init__(self, region, key=None, secret=None, host=None):
33
36
self .connection = connection .S3Connection (
34
37
host = host ,
35
38
aws_access_key_id = key ,
36
- aws_secret_access_key = secret )
39
+ aws_secret_access_key = secret ,
40
+ calling_format = ProtocolIndependentOrdinaryCallingFormat ())
37
41
else :
38
42
self .connection = connect_to_region (
39
43
region ,
40
44
aws_access_key_id = key ,
41
- aws_secret_access_key = secret )
45
+ aws_secret_access_key = secret ,
46
+ calling_format = ProtocolIndependentOrdinaryCallingFormat ())
42
47
43
48
def bucket (self , name , create = False ):
44
49
for _ in range (6 ):
@@ -51,7 +56,7 @@ def bucket(self, name, create=False):
51
56
raise
52
57
53
58
54
- class Bucket (object ):
59
+ class Bucket (BaseBucket ):
55
60
56
61
PART_LIMIT = (4 << 30 ) # 4 GB
57
62
@@ -80,3 +85,11 @@ def put(self, source, target):
80
85
def get (self , source , target ):
81
86
key = self .handle .get_key (source , validate = False )
82
87
key .get_contents_to_filename (target )
88
+
89
+ def has (self , source ):
90
+ key = self .handle .get_key (source , validate = False )
91
+ return key .exists ()
92
+
93
+ def list (self , prefix = None ):
94
+ for key in self .handle .get_all_keys (prefix = prefix ):
95
+ yield key
0 commit comments