I'm wondering where you got the idea that your custom handler is a function 
that goes into your view. From what I'm reading 
(http://docs.djangoproject.com/en/dev/topics/http/file-uploads/#upload-handlers)
 it looks like a custom handler needs to be a class that implements at least 
receive_data_chunk(self, raw_data, start) and file_complete(self, file_size).

(As an aside, if you're using Python 2.5 or greater you might consider using 
the 'with' statement in your handler... 
<http://www.python.org/doc/2.5.2/ref/with.html>)

Best wishes,
Michael A. Smith
Web & Digital / Academic Technologies Manager
Nazareth College

----- "Brandon Taylor" <btaylordes...@gmail.com> wrote:

> Hi Everyone,
> 
> I'm confused about creating a custom upload handler and how it ties
> into my model. From the docs, this is an example of a custom upload
> handler, which I'm assuming goes in my view, or is accessed from my
> view:
> 
> def handle_uploaded_file(f):
>     destination = open('some/file/name.txt', 'wb+')
>     for chunk in f.chunks():
>         destination.write(chunk)
>     destination.close()
> 
> 
> Let's say my model is:
> 
> class MyModel(models.Model):
>     my_file = models.FileField(upload_to='uploads/')
> 
> 
> How do the FileField "my_file" and the handler
> "handled_uploaded_file"
> work together? In my project, I need to allow users to upload large-
> ish files. Say 10 - 20 MB. What's the best way to handle this
> functionality? I would sincerely appreciate an example if someone has
> one.
> 
> Kindest Regards,
> Brandon
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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

Reply via email to