Views

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

Browse a directory on your server. Returns a FileListing class:

http://mysite.com/adminurl/filebrowser/browse/
  • URL: fb_browse
  • Optional query string args: dir, o, ot, q, p, filter_date, filter_type, type

Create directory

Create a new folder on your server:

http://mysite.com/adminurl/filebrowser/createdir/

Upload

Multiple upload:

http://mysite.com/adminurl/filebrowser/upload/

Edit

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 delete

Confirm the deletion of a file or folder:

http://mysite.com/adminurl/filebrowser/confirm_delete/?filename=testimage.jpg
  • URL: fb_confirm_delete
  • Required query string args: filename
  • Optional query string args: dir

Note

If you try to delete a folder, all files/folders within this folder are listed on this page.

Delete

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.

Version

Generate a version of an Image as defined with ADMIN_VERSIONS:

http://mysite.com/adminurl/filebrowser/version/?filename=testimage.jpg
  • URL: fb_version
  • Required query string args: filename
  • Query string args: dir

Note

This is a helper used by the FileBrowseField and TinyMCE for selecting an Image-Version.

Signals

The FileBrowser sends a couple of different signals:

filebrowser_pre_upload

Sent before a an Upload starts. Arguments:

  • path: Absolute server path to the file/folder
  • name: Name of the file/folder
  • site: Current FileBrowserSite instance

filebrowser_post_upload

Sent after an Upload has finished. Arguments:

  • path: Absolute server path to the file/folder
  • name: Name of the file/folder
  • site: Current FileBrowserSite instance

filebrowser_pre_delete

Sent before an Item (File, Folder) is deleted. Arguments:

  • path: Absolute server path to the file/folder
  • name: Name of the file/folder
  • site: Current FileBrowserSite instance

filebrowser_post_delete

Sent after an Item (File, Folder) has been deleted. Arguments:

  • path: Absolute server path to the file/folder
  • name: Name of the file/folder
  • site: Current FileBrowserSite instance

filebrowser_pre_createdir

Sent before a new Folder is created. Arguments:

  • path: Absolute server path to the folder
  • name: Name of the new folder
  • site: Current FileBrowserSite instance

filebrowser_post_createdir

Sent after a new Folder has been created. Arguments:

  • path: Absolute server path to the folder
  • name: Name of the new folder
  • site: Current FileBrowserSite instance

filebrowser_pre_rename

Sent before an Item (File, Folder) is renamed. Arguments:

  • path: Absolute server path to the file/folder
  • name: Name of the file/folder
  • new_name: New name of the file/folder
  • site: Current FileBrowserSite instance

filebrowser_post_rename

Sent after an Item (File, Folder) has been renamed.

  • path: Absolute server path to the file/folder
  • name: Name of the file/folder
  • new_name: New name of the file/folder
  • site: Current FileBrowserSite instance

filebrowser_actions_pre_apply

Sent before a custom action is applied. Arguments:

  • action_name: Name of the custom action
  • fileobjects: A list of fileobjects the action will be applied to
  • site: Current FileBrowserSite instance

filebrowser_actions_post_apply

Sent after a custom action has been applied.

  • action_name: Name of the custom action
  • fileobjects: A list of fileobjects the action has been be applied to
  • results: The response you defined with your custom action
  • site: Current FileBrowserSite instance

Example for using these Signals

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)
Read the Docs v: 3.5.2
Versions
latest
3.5.2
3.4.3
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.