Hi all -

I have a site that allows users to upload files. I would like to store
the files to settings.MEDIA_ROOT + os.sep + logged_in_user + os.sep +
filename (that is, the files uploaded by a given user will be uploaded
to a subdirectory of settings.MEDIA_ROOT specific to that user).

I can't set "upload_to" in the model to the correct location, because
no logged-in user exists at that point.

I am currently doing the saving manually in the view, pretty much
totally ignoring the "upload_to", which seems wrong, and must be wrong
because when I attempt to delete the file object I trigger a
SuspiciousOperation exception - presumably because Django has no idea
that I've been doing sneaky things behind the scenes.

So my question is more or less twofold: (1) what is the best way to
upload files to a path determined dynamically, possible from a logged
in user's ID or something from a form? and (2) is the solution a
custom storage class? If so, how would that be accomplished? When is
the custom storage class instantiated? The docs aren't totally clear
on the minutiae of how that works.

Thanks for any help!

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