Hi,
Some code is below. I am in my FileSystemStorage class and I want to prevent 
users from uploading images over 100K. 
There are 2 questions here:
1. Is my use of len(content) sensible? I don't have a file yet, only a memory 
object, so I can't use stat.
2. How would I raise an error so that it appears in the admin form?

Code:

class myImageStorage( FileSystemStorage ):
        def save(self, name, content ):
                lenf = len(content) # Is this right?
                if lenf > 102400:
                # WHAT do I do here?
                        return "FILE TOO LARGE %s" % len(content) # not good...

                dud = super( myImageStorage,self)._save(name,content)
                return name

i = myImageStorage( location = blah, base_url = blahblah ) 
                
class ImageMedia(models.Model):
        image = models.ImageField( storage = i, blank = False, upload_to="./" )

Many thanks,
\d

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to