Changes between Version 2 and Version 3 of AmazonSimpleStorageService


Ignore:
Timestamp:
Jun 7, 2007, 7:44:04 PM (17 years ago)
Author:
dobesv@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AmazonSimpleStorageService

    v2 v3  
    2222from django.utils.translation import gettext_lazy
    2323from django.db.models import signals
     24from PIL import Image
     25from StringIO import StringIO
    2426import os
    2527
     
    7072    def contribute_to_class(self, cls, name):
    7173        super(S3FileField, self).contribute_to_class(cls, name)
    72         #models.CharField(maxlength=200, blank=self.blank, null=self.null).contribute_to_class(cls, "%s_filename"%(self.name))
    7374        models.CharField(maxlength=200, blank=self.blank, null=self.null).contribute_to_class(cls, "%s_key"%(self.name))
    7475        models.CharField(maxlength=200, blank=self.blank, null=self.null, default=settings.DEFAULT_BUCKET).contribute_to_class(cls, "%s_bucket"%(self.name))
     
    167168           
    168169            self.set_filename(new_object, new_filename)
     170            self.set_size(new_object, len(new_content))
     171           
    169172            key = new_data["%s_key"%self.name]
    170173            bucket = new_data["%s_bucket"%self.name]
     
    179182            conn.put(bucket, key, S3.S3Object(new_content),
    180183                     { 'x-amz-acl': 'public-read' , 'Content-Type': content_type})
    181             # TODO Calculate image width/height
    182184           
    183 
     185            if self.is_image:
     186                # Calculate image width/height
     187                img = Image.open(StringIO(new_content))
     188                width, height = img.size
     189                self.set_width(new_object, width)
     190                self.set_height(new_object, height)
    184191}}}
Back to Top