s3: put image size as metadata

--HG--
extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40427
This commit is contained in:
Daniel Grana 2008-11-25 20:51:02 +00:00
parent 664a72490f
commit 537a3457cf
1 changed files with 5 additions and 2 deletions

View File

@ -95,7 +95,7 @@ class S3ImagesPipeline(BaseImagesPipeline):
age_seconds = time.time() - modified_stamp
age_days = age_seconds / 60 / 60 / 24
if age_days > self.image_refresh_days:
if age_days < self.image_refresh_days:
return # returning None force download
etag = response.headers['Etag'][0].strip('"')
@ -136,13 +136,16 @@ class S3ImagesPipeline(BaseImagesPipeline):
image.save(buf, 'JPEG')
except Exception, ex:
raise ImageException("Cannot process image. Error: %s" % ex)
buf.seek(0)
width, height = image.size
headers = {
'Content-Type': 'image/jpeg',
'X-Amz-Acl': 'public-read',
'X-Amz-Meta-Width': str(width),
'X-Amz-Meta-Height': str(height),
}
buf.seek(0)
req = self.s3request(key, method='PUT', body=buf.read(), headers=headers)
return self.download(req, info), buf