Comments on: django and amazon s3 http://coder.cl/2012/01/django-and-amazon-s3/ web developer & system programmer Wed, 17 Oct 2012 11:33:51 +0000 hourly 1 http://wordpress.org/?v=3.4.2 By: how to get a 304 for images stored on amazon s3 when using django-storages on django app? http://coder.cl/2012/01/django-and-amazon-s3/#comment-193 how to get a 304 for images stored on amazon s3 when using django-storages on django app? Tue, 27 Mar 2012 07:17:42 +0000 http://coder.cl/?p=2183#comment-193 [...] EDIT 1: I read this article and couldn’t translate it very well.. http://coder.cl/2012/01/django-and-amazon-s3/comment-page-1/ [...] [...] EDIT 1: I read this article and couldn’t translate it very well.. http://coder.cl/2012/01/django-and-amazon-s3/comment-page-1/ [...]

]]>
By: Daniel Molina Wegener http://coder.cl/2012/01/django-and-amazon-s3/#comment-192 Daniel Molina Wegener Fri, 23 Mar 2012 09:10:58 +0000 http://coder.cl/?p=2183#comment-192 <p>Well, if you are using the python-boto library, this patch will not work for you. I have not tested boto with django-storages, sorry. Try the other backend library for django-storages. With boto you need to configure the <tt>/etc/boto.cfg</tt> file.</p> Well, if you are using the python-boto library, this patch will not work for you. I have not tested boto with django-storages, sorry. Try the other backend library for django-storages. With boto you need to configure the /etc/boto.cfg file.

]]>
By: Travis http://coder.cl/2012/01/django-and-amazon-s3/#comment-191 Travis Fri, 23 Mar 2012 08:09:50 +0000 http://coder.cl/?p=2183#comment-191 maybe i should mention i am using.. DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' maybe i should mention i am using.. DEFAULT_FILE_STORAGE = ‘storages.backends.s3boto.S3BotoStorage’

]]>
By: Travis http://coder.cl/2012/01/django-and-amazon-s3/#comment-190 Travis Fri, 23 Mar 2012 07:58:52 +0000 http://coder.cl/?p=2183#comment-190 I'm confused, what is actually referencing the S3.py file that would make these changes make a difference? These changes are to be made on S3.py, right? I’m confused, what is actually referencing the S3.py file that would make these changes make a difference? These changes are to be made on S3.py, right?

]]>
By: Daniel Molina Wegener http://coder.cl/2012/01/django-and-amazon-s3/#comment-189 Daniel Molina Wegener Sat, 17 Mar 2012 21:56:05 +0000 http://coder.cl/?p=2183#comment-189 <p>Check that S3 is not using versioning if you are replacing files. Also, there is a bug as it is linked on the post, please check the issue #56 of the django-storages and follow my patch, rather than using those example lines on the issue comments.</p> <p>If you do not want to use the localized date, you should use a GMT version that works, as follows:</p> <pre name="code" class="brush:python;"> def _add_aws_auth_header(self, headers, method, bucket, key, query_args): if not headers.has_key('Date'): headers['Date'] = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()) c_string = canonical_string(method, bucket, key, query_args, headers) headers['Authorization'] = "AWS %s:%s" % (self.aws_access_key_id, encode(self.aws_secret_access_key, c_string)) </pre> Check that S3 is not using versioning if you are replacing files. Also, there is a bug as it is linked on the post, please check the issue #56 of the django-storages and follow my patch, rather than using those example lines on the issue comments.

If you do not want to use the localized date, you should use a GMT version that works, as follows:

    def _add_aws_auth_header(self, headers, method, bucket, key, query_args):
        if not headers.has_key('Date'):
            headers['Date'] = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime())

        c_string = canonical_string(method, bucket, key, query_args, headers)
        headers['Authorization'] = 
            "AWS %s:%s" % (self.aws_access_key_id, encode(self.aws_secret_access_key, c_string))
]]>
By: Travis http://coder.cl/2012/01/django-and-amazon-s3/#comment-188 Travis Sat, 17 Mar 2012 21:43:10 +0000 http://coder.cl/?p=2183#comment-188 I wish I could get this working properly. When django requests the image I have stored on S3 it will never get a 304, but when I copy the link to the image and paste it in a new window it will first 200, then any requests after will 304... Frustrated. Any tips? I have set the AWS_HEADER variable in my settings like specified in the django-storage docs. Are you suggesting that everything you mentioned above must be done in order to get a 304? I wish I could get this working properly. When django requests the image I have stored on S3 it will never get a 304, but when I copy the link to the image and paste it in a new window it will first 200, then any requests after will 304… Frustrated. Any tips?

I have set the AWS_HEADER variable in my settings like specified in the django-storage docs. Are you suggesting that everything you mentioned above must be done in order to get a 304?

]]>