Skip to content

Commit

Permalink
Add min size to docs and fix raise
Browse files Browse the repository at this point in the history
  • Loading branch information
artwr committed Nov 12, 2015
1 parent 4e12fbc commit 6edd903
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions airflow/hooks/S3_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ def load_file(
error will be raised.
:type replace: bool
:param multipart_bytes: If provided, the file is uploaded in parts of
this size. If None, the whole file is uploaded at once.
this size (minimum 5242880). If None, the whole file is uploaded at
once.
:type multipart_bytes: int
"""
if not bucket_name:
Expand Down Expand Up @@ -358,10 +359,12 @@ def load_string(self, string_data,
if not bucket_name:
(bucket_name, key) = self.parse_s3_url(key)
bucket = self.get_bucket(bucket_name)
if not self.check_for_key(key, bucket_name):
key_obj = bucket.get_key(key)
if not replace and key_obj:
raise ValueError("The key {key} already exists.".format(
**locals()))
if not key_obj:
key_obj = bucket.new_key(key_name=key)
else:
key_obj = bucket.get_key(key)
key_size = key_obj.set_contents_from_string(string_data,
replace=replace)
logging.info("The key {key} now contains"
Expand Down

0 comments on commit 6edd903

Please sign in to comment.