GoodCloud/django-ajax-uploader — pull request #47 by fcurella (2013-04-29 17:02:10+00:00)
Title: callable UPLOAD_DIR

This modifies the way the 'UPLOAD_DIR' property is handled by the `DefaultStorageUploadBackend` to make it more similar to Django FileFiels `upload_to` option.

enables the following patterns:

```
# views.py

from ajaxuploader.views import AjaxFileUploader
from ajaxuploader.backends.default_storage import DefaultStorageUploadBackend

ajax_uploader = AjaxFileUploader(backend=DefaultStorageUploadBackend, UPLOAD_DIR='uploads/%Y/%m/%d')
```

or:

```
# views.py

from ajaxuploader.views import AjaxFileUploader
from ajaxuploader.backends.default_storage import DefaultStorageUploadBackend

ajax_uploader = AjaxFileUploader(backend=DefaultStorageUploadBackend, UPLOAD_DIR=lambda: something_crazy())
```

or, if more customization is needed:

```
# views.py

from ajaxuploader.views import AjaxFileUploader
from ajaxuploader.backends.default_storage import DefaultStorageUploadBackend

class MyPathUploader(DefaultStorageUploadBackend):
def get_upload_dir(self):
return crazy_calculation_maybe_hash()

ajax_uploader = AjaxFileUploader(backend=MyPathUploader)
```