@@ -65,6 +65,8 @@ def objects(self):
6565 :since: 0.8.0
6666 """
6767
68+ self ._logger .debug (f"Returning all S3 bucket objects for { self ._bucket .name } " )
69+
6870 return self ._bucket .objects .all ()
6971
7072 def __getattr__ (self , name ):
@@ -80,3 +82,59 @@ class tree for self).
8082 """
8183
8284 return getattr (self ._bucket , name )
85+
86+ def download_file (self , key , file_name , * args , ** kwargs ):
87+ """
88+ boto3: Download an S3 object to a file.
89+
90+ :param key: The name of the key to download from.
91+ :param file_name: The path to the file to download to.
92+
93+ :since: 0.8.0
94+ """
95+
96+ self ._bucket .download_file (key , file_name , * args , ** kwargs )
97+
98+ self ._logger .info (f"Downloaded { key } from S3 to { file_name } " )
99+
100+ def download_fileobj (self , key , fp , * args , ** kwargs ):
101+ """
102+ boto3: Download an object from this bucket to a file-like-object.
103+
104+ :param key: The name of the key to download from.
105+ :param fp: A file-like object to download into.
106+
107+ :since: 0.8.0
108+ """
109+
110+ self ._bucket .download_fileobj (key , fp , * args , ** kwargs )
111+
112+ self ._logger .info (f"Downloaded { key } from S3 as binary data" )
113+
114+ def upload_file (self , file_name , key , * args , ** kwargs ):
115+ """
116+ boto3: Upload a file to an S3 object.
117+
118+ :param file_name: The path to the file to upload.
119+ :param key: The name of the key to upload to.
120+
121+ :since: 0.8.0
122+ """
123+
124+ self ._bucket .upload_file (file_name , key , * args , ** kwargs )
125+
126+ self ._logger .info (f"Uploaded { key } to S3 for { file_name } " )
127+
128+ def upload_fileobj (self , fp , key , * args , ** kwargs ):
129+ """
130+ boto3: Upload a file-like object to this bucket.
131+
132+ :param fp: A file-like object to upload.
133+ :param key: The name of the key to upload to.
134+
135+ :since: 0.8.0
136+ """
137+
138+ self ._bucket .upload_fileobj (fp , key , * args , ** kwargs )
139+
140+ self ._logger .info (f"Uploaded { key } to S3 as binary data" )
0 commit comments