Changes between Version 2 and Version 3 of AmazonSimpleStorageService
- Timestamp:
- Jun 7, 2007, 7:44:04 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AmazonSimpleStorageService
v2 v3 22 22 from django.utils.translation import gettext_lazy 23 23 from django.db.models import signals 24 from PIL import Image 25 from StringIO import StringIO 24 26 import os 25 27 … … 70 72 def contribute_to_class(self, cls, name): 71 73 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))73 74 models.CharField(maxlength=200, blank=self.blank, null=self.null).contribute_to_class(cls, "%s_key"%(self.name)) 74 75 models.CharField(maxlength=200, blank=self.blank, null=self.null, default=settings.DEFAULT_BUCKET).contribute_to_class(cls, "%s_bucket"%(self.name)) … … 167 168 168 169 self.set_filename(new_object, new_filename) 170 self.set_size(new_object, len(new_content)) 171 169 172 key = new_data["%s_key"%self.name] 170 173 bucket = new_data["%s_bucket"%self.name] … … 179 182 conn.put(bucket, key, S3.S3Object(new_content), 180 183 { 'x-amz-acl': 'public-read' , 'Content-Type': content_type}) 181 # TODO Calculate image width/height182 184 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) 184 191 }}}