title: Multipart upload to Amazon Glacier: Content-Range incompatible with Content-Length
body: <p>I'm trying to upload a file around 1gb in size to Amazon Glacier. Somewhat arbitrarily, I've decided to break it into 32mb parts and upload them in serial.</p>
  
  <pre class="lang-py prettyprint-override"><code>import math
  import boto3
  from botocore.utils import calculate_tree_hash
  
  client = boto3.client('glacier')
  vault_name = 'my-vault'
  size = 1073745600 # in bytes
  size_mb = size / (2**20) # Convert to megabytes for readability
  local_file = 'filename'
  
  multi_up = client.initiate_multipart_upload(vaultName=vault_name,
                                          archiveDescription=local_file,
                                          partSize=str(2**25)) # 32 mb in bytes
  parts = math.floor(size_mb / 32)
  with open("/Users/alexchase/Desktop/{}".format(local_file), 'rb') as upload:
      for p in range(parts):
          # Calculate lower and upper bounds for the byte ranges. The last range
          # is bigger than the ones that come before.
          lower = (p * (2**25))
          upper = (((p + 1) * (2**25)) - 1) if (p + 1 &lt; parts) else (size)
          up_part = client.upload_multipart_part(vaultName=vault_name,
                                             uploadId=multi_up['uploadId'],
                                             range='bytes {}-{}/*'.format(lower, upper),
                                             body=upload)
  checksum = calculate_tree_hash(upload)
  complete_up = client.complete_multipart_upload(archiveSize=str(size),
                                                 checksum=checksum,
                                                 uploadId=multi_up['uploadId'],
                                                 vaultName=vault_name)
  </code></pre>
  
  <p>This generates an error about the first byte range.</p>
  
  <pre class="lang-py prettyprint-override"><code>---------------------------------------------------------------------------
  InvalidParameterValueException            Traceback (most recent call last)
  &lt;ipython-input-2-9dd3ac986601&gt; in &lt;module&gt;()
       93                         uploadId=multi_up['uploadId'],
       94                         range='bytes {}-{}/*'.format(lower, upper),
  ---&gt; 95                         body=upload)
       96                     upload_info.append(up_part)
       97                 checksum = calculate_tree_hash(upload)
  
  ~/anaconda/lib/python3.5/site-packages/botocore/client.py in _api_call(self, *args, **kwargs)
      251                     "%s() only accepts keyword arguments." % py_operation_name)
      252             # The "self" in this scope is referring to the BaseClient.
  --&gt; 253             return self._make_api_call(operation_name, kwargs)
      254
      255         _api_call.__name__ = str(py_operation_name)
  
  ~/anaconda/lib/python3.5/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params)
      555             error_code = parsed_response.get("Error", {}).get("Code")
      556             error_class = self.exceptions.from_code(error_code)
  --&gt; 557             raise error_class(parsed_response, operation_name)
      558         else:
      559             return parsed_response
  
  InvalidParameterValueException: An error occurred (InvalidParameterValueException) when calling the UploadMultipartPart operation:
  Content-Range: bytes 0-33554431/* is incompatible with Content-Length: 1073745600
  </code></pre>
  
  <p>Can anyone see what I'm doing wrong?</p>