I have a custom file storage working with a specific subdir structure.

Did you pass in a method specifying the path in the upload_to kwarg
for FileField?

Here's my model code, where EnhancedFileSystemStorage is my custom
file storage class, and get_random_dir_name is just a helper method
that does exactly as named.

    file_storage = EnhancedFileSystemStorage(location=settings.DYNMEDIA_ROOT,
                                             base_url=settings.DYNMEDIA_URL)

    def file_upload_to(instance, filename):
        return os.path.join(get_random_dir_name(instance.file_storage.location,
filename), filename)

    file = models.FileField(upload_to=file_upload_to, storage=file_storage)

On 9 December 2010 05:24, dmitry b <dmitry.ma...@gmail.com> wrote:
> Hi,
>
> I've written a custom Storage that uses WebDAV as its underlying
> engine.  When I save a file '/foo/bar/file.ext', I want it to be saved
> under /foo/bar in the webdav filesystem.  However, it seems that
> FileField overrides the directory structure:
>
>    def generate_filename(self, instance, filename):
>        return os.path.join(self.get_directory_name(),
> self.get_filename(filename))
>
> where get_directory_name() is defined as
>
>    def get_directory_name(self):
>        return
> os.path.normpath(force_unicode(datetime.datetime.now().strftime(smart_str(self.upload_to))))
>
> I'm not really sure why FileField finds it appropriate to impose its
> own directory structure on the underlying storage engine.  But short
> of creating a custom subclass of FileField and overriding
> generate_filename and/or get_directory_name(), is there a different
> way of preserving the original file location path?
>
>
> Thanks
> Dmitry
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to