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 -~----------~----~----~----~------~----~------~--~---
