All views use the staff_member_requird and path_exists decorator in order to check if the server path actually exists. Some views also use the file_exists decorator.
Browse a directory on your server. Returns a FileListing class:
http://mysite.com/adminurl/filebrowser/browse/
Create a new folder on your server:
http://mysite.com/adminurl/filebrowser/createdir/
Multiple upload:
http://mysite.com/adminurl/filebrowser/upload/
Edit a file or folder:
http://mysite.com/adminurl/filebrowser/edit/?filename=testimage.jpg
You are able to apply custom actions (see Custom Actions) to the edit-view.
Note
This won’t check if you use the file or folder anywhere with your models.
Confirm the deletion of a file or folder:
http://mysite.com/adminurl/filebrowser/confirm_delete/?filename=testimage.jpg
Note
If you try to delete a folder, all files/folders within this folder are listed on this page.
Delete a file or folder:
http://mysite.com/adminurl/filebrowser/delete/?filename=testimage.jpg
Note
This won’t check if you use the file or folder anywhere with your models.
Warning
If you delete a Folder, all items within this Folder are being deleted.
Generate a version of an Image as defined with ADMIN_VERSIONS:
http://mysite.com/adminurl/filebrowser/version/?filename=testimage.jpg
Note
This is a helper used by the FileBrowseField and TinyMCE for selecting an Image-Version.
The FileBrowser sends a couple of different signals:
Sent before a an Upload starts. Arguments:
Sent after an Upload has finished. Arguments:
Sent before an Item (File, Folder) is deleted. Arguments:
Sent after an Item (File, Folder) has been deleted. Arguments:
Sent before a new Folder is created. Arguments:
Sent after a new Folder has been created. Arguments:
Sent before an Item (File, Folder) is renamed. Arguments:
Sent after an Item (File, Folder) has been renamed.
Sent before a custom action is applied. Arguments:
Sent after a custom action has been applied.
Here’s a small example for using the above Signals:
from filebrowser import signals
def pre_upload_callback(sender, **kwargs):
"""
Receiver function called before an upload starts.
"""
print "Pre Upload Callback"
print "kwargs:", kwargs
signals.filebrowser_pre_upload.connect(pre_upload_callback)
def post_upload_callback(sender, **kwargs):
"""
Receiver function called each time an upload has finished.
"""
print "Post Upload Callback"
print "kwargs:", kwargs
# You can use all attributes available with the FileObject
# This is just an example ...
print "Filesize:", kwargs['file'].filesize
print "Orientation:", kwargs['file'].orientation
print "Extension:", kwargs['file'].extension
signals.filebrowser_post_upload.connect(post_upload_callback)