Hi Malcolm,

Not sure if we're talking about the same thing here. What I ask is if
it'd be a good idea to have a generic method for UploadedFile which
lets copy/move the file to where ever you want. These method would
have to be overriden by InMemoryUploadedFile or TemporaryUploadedFile,
but would allow to have something as simple as:

uploaded_file.move_to("some/path/")

I agree with Ivan that it is a common operation and that having it
core in the API would avoid some boilerplate code, and as result that
would prevent potential mistakes by the developer.

On Jul 11, 5:13 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2008-07-10 at 22:31 -0700, Julien Phalip wrote:
> > Hi,
>
> > I see what may be a gap in the new upload system's API. Please correct
> > me or point me to the right place if I'm wrong.
>
> > Once the file is uploaded and my view receives the UploadedFile
> > instance, I'd like to write the file on disk to my chosen path. The
> > API already provides a proxy for the common file operations, which is
> > great, but I wonder how I could actually do the writing/copying to the
> > right path without clogging up the memory.
>
> The docs already mention looping over chunks(). However, given that the
> file exists on disk (which is something you can check for), and you have
> access to the full filename, it seems like for simple file copies/moves,
> using the standard Python shutil module solves all your problems here.
>
> The chunks() solution is necessary if you're doing something a bit nuts
> like sending it straight to S3 without storing it on disk (something
> which would be a bad idea, but I'm sure that won't stop people trying it
> in much the same way as people run with scissors), but for normal
> filesystem operations, use the normal filesystem approach.
>
> Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to