﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
651	Allow directories in filename argument to save_<fieldname>_file	Adam Endicott <leftwing17@…>	Philippe Raoult	"Currently, all files associated with !FileFields are uploaded into a single directory specified by MEDIA_ROOT and upload_to. There is no way to specify directories on a per-file basis when files are uploaded. With this patch, if the filename argument to save_<fieldname>_file specifies a directory as well as a filename, the file will be uploaded to that directory under the MEDIA_ROOT/upload_to directory. Example:

{{{
#!python
class File(meta.Model):
    file = meta.FileField(upload_to='baseDir')
    name = meta.CharField(maxlength=100)
}}}

{{{
#!python
newFile = files.File(name='my file')
newFile.save_file_file('some/sub/directory/myFile.txt', 'Some text content')
}}}
The above lines will create a file at: <MEDIA_ROOT>/baseDir/some/sub/directory/myFile.txt.

This shouldn't change how most file uploading (including the admin app) works now, because normally just a filename without any directories is passed to save_<fieldname>_file. However, it allows custom view code or !FileField subclasses (each of which will call save_<fieldname>_file) to save files to specific locations easily."	enhancement	closed	Core (Other)		normal	duplicate	fs-rf-fixed		Design decision needed	0	0	0	0	0	0
