So I am trying to modify django-jfu ( a multi uploader) to send files to a 
unique directory for every unique upload session performed.  This is just 
due to my application's requirements and to prevent file collisions during 
the operations later down the road in my app.

Anyway, here is views.py (I think the most relevant portion anyway, I could 
be wrong)

def upload( request ):

    # The assumption here is that jQuery File Upload
    # has been configured to send files one at a time.
    # If multiple files can be uploaded simulatenously,
    # 'file' may be a list of files.
    #Create the file object
    file = upload_receive( request )

    #Create an instance of our Uploader Class and pass it the file object
    instance = UpFile ( file = file )
    #Save the file object
    instance.save() 

And the "UpFile" class in models.py:

class UpFile(models.Model):
    file = models.FileField( upload_to = 
MEDIA_ROOT+'/'+"".join([random.choice(string.ascii_letters) for n in 
xrange(12)]))

The problem I am having is that it appears that the "random" section at the 
tail end of the "upload_to" option in models,py is processed only once when 
the server is started (or restarted).

This won't work for my particular application, as I need the "top level" 
for any uploaded of a set of files to be unique.

For example if I have the following "upload sessions"

Session 1:  User only uploaded a single file.  A new random/unique 
directory should be generated under MEDIA_ROOT, and the file should be 
placed in that directory.
Session 2:  User uploaded 2 files.  A new random/unique directory should be 
generated under MEDIA_ROOT, and BOTH files should be uploaded to that 
directory (NOT a different directory per file)
Session 3:  User uploaded 100 files.  Like session 2 above, a new 
random/unique directory should be generated under MEDIA_ROOT and all 100 
files should be placed underneath.

Later on I plan on cleaning house, but for now simply getting that logic 
down will get me moving again...

Thanks for any help you can provide.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/49b570f3-20d0-46f0-bffe-dff7ad14cdd4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to