1. David Larlet
  2. django-storages
  3. Issues

Issues

Issue #46 new

Initial File Creation Errors Out with a MD5 Mis-Match on S3Boto

Jason Christa
created an issue

This is basically the code I am using:

{{{ from django.core.files.base import File from backends.s3boto import S3BotoStorage

storage = S3BotoStorage()

image = open(r'image.png', 'rb') file = File(image) try: name = storage.save('image.png', file) finally: file.close() print storage.url(name) }}}

Does anyone else have this problem?

Comments (2)

  1. rgcarrasqueira

    Hi!

    I'm having the same problem creating files with 3-4Mb on S3, or creating files on the fly (for example a csv report that is incremented due the results from a program process). See the stacktrace bellow:

    2014-04-04 16:07:58,925: WARNING/PoolWorker-5] Exception in thread Thread-9:
    Traceback (most recent call last):
      File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
        self.run()
      File "/usr/lib/python2.7/threading.py", line 504, in run
        self.__target(*self.__args, **self.__kwargs)
      File "/home/myapp/production/web_app/myapp.panel/core/utils/import_utils.py", line 290, in save_contact
        proccess_contact_list(contacts, report)
      File "/home/myapp/production/web_app/myapp.panel/core/utils/import_utils.py", line 251, in proccess_contact_list
        report.writerow([contact.name, contact.email, '%s' % result])
      File "/usr/local/lib/python2.7/dist-packages/storages/backends/s3boto.py", line 160, in write
        self._flush_write_buffer()
      File "/usr/local/lib/python2.7/dist-packages/storages/backends/s3boto.py", line 180, in _flush_write_buffer
        self.file, self._write_counter, headers=headers)
      File "/usr/local/lib/python2.7/dist-packages/boto/s3/multipart.py", line 260, in upload_part_from_file
        query_args=query_args, size=size)
      File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1244, in set_contents_from_file
        chunked_transfer=chunked_transfer, size=size)
      File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 723, in send_file
        chunked_transfer=chunked_transfer, size=size)
      File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 912, in _send_file_internal
        query_args=query_args
      File "/usr/local/lib/python2.7/dist-packages/boto/s3/connection.py", line 550, in make_request
        retry_handler=retry_handler
      File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 1021, in make_request
        retry_handler=retry_handler)
      File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 898, in _mexe
        request.body, request.headers)
      File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 850, in sender
        response.status, response.reason, body)
    S3ResponseError: S3ResponseError: 400 Bad Request
    <?xml version="1.0" encoding="UTF-8"?>
    <Error><Code>BadDigest</Code><Message>The Content-MD5 you specified did not match what we received.</Message><ExpectedDigest>WGCEDWK7W2yyPL3TlCvNHA==</ExpectedDigest><CalculatedDigest>MZO5zZhhHkmHM0wgIvTuoA==</CalculatedDigest><RequestId>05FD72CE5BDEE529</RequestId><HostId>jF8dNvFOUFi/Vre2TcdoptY3zLgrC7LYsVOOxdhlFP7kgfmkwnysvI7l/tXByPz8</HostId></Error>
    
  2. Log in to comment