Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Properly pass multipart enabling, default enabled on > 100MB

  • Loading branch information...
commit abd57a8a3b2883ef2c60028260192c70bff46721 1 parent 32c846c
@jleclanche jleclanche authored mludvig committed
Showing with 11 additions and 4 deletions.
  1. +5 −1 S3/S3.py
  2. +6 −3 s3cmd
View
6 S3/S3.py
@@ -330,6 +330,10 @@ def object_put(self, filename, uri, extra_headers = None, extra_label = "", mult
if extra_headers:
headers.update(extra_headers)
+ if not multipart:
+ if size > 104857600: # 100MB
+ multipart = True
+
if multipart:
# Multipart requests are quite different... drop here
return self.send_file_multipart(file, headers, uri, size)
@@ -731,7 +735,7 @@ def send_file_multipart(self, file, headers, uri, size):
chunk_size = self.config.multipart_chunk_size or MultiPartUpload.MIN_CHUNK_SIZE
file.seek(0)
- upload.upload_all_parts()
+ upload.upload_all_parts(num_threads, chunk_size)
response = upload.complete_multipart_upload(num_threads, chunk_size)
response["speed"] = 0 # XXX
return response
View
9 s3cmd
@@ -241,7 +241,7 @@ def cmd_bucket_delete(args):
_bucket_delete_one(uri)
output(u"Bucket '%s' removed" % uri.uri())
-def cmd_object_put(args):
+def cmd_object_put(args, multipart):
cfg = Config()
s3 = S3(cfg)
@@ -296,7 +296,7 @@ def cmd_object_put(args):
if Config().encrypt:
exitcode, full_name, extra_headers["x-amz-meta-s3tools-gpgenc"] = gpg_encrypt(full_name_orig)
try:
- response = s3.object_put(full_name, uri_final, extra_headers, extra_label = seq_label, multipart = True) # XXX temporarily forcing multipart=True
+ response = s3.object_put(full_name, uri_final, extra_headers, extra_label = seq_label, multipart = multipart)
except S3UploadError, e:
error(u"Upload of '%s' failed too many times. Skipping that file." % full_name_orig)
continue
@@ -1709,7 +1709,10 @@ def main():
sys.exit(1)
try:
- cmd_func(args)
+ if cmd_func == cmd_object_put:
+ cmd_func(args, options.enable_multipart)
+ else:
+ cmd_func(args)
except S3Error, e:
error(u"S3 error: %s" % e)
sys.exit(1)
Please sign in to comment.
Something went wrong with that request. Please try again.