Skip to content

Commit

Permalink
Added upload and upload_file.
Browse files Browse the repository at this point in the history
  • Loading branch information
GendoIkari committed Jan 31, 2017
1 parent 751c36d commit fc31d79
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions s3archive/s3archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,14 @@ def find(self, regex):
def exists(self, regex):
"""Returns False if there are no matches for the given regex."""
return bool(next(self.find(regex), None))

def upload(self, source, destination):
"""Uploads a file from the given source to the given destination on S3."""
self.upload_file(open(source, 'rb'), destination)

def upload_file(self, file_object, destination):
"""Uploads a file to S3 with the given destination."""
self.bucket.put_object(
Key=destination,
Body=file_object,
)

0 comments on commit fc31d79

Please sign in to comment.