Skip navigation
Help

hook_filetransfer_info

7 system.api.php hook_filetransfer_info()

Register information about FileTransfer classes provided by a module.

The FileTransfer class allows transfering files over a specific type of connection. Core provides classes for FTP and SSH. Contributed modules are free to extend the FileTransfer base class to add other connection types, and if these classes are registered via hook_filetransfer_info(), those connection types will be available to site administrators using the Update manager when they are redirected to the authorize.php script to authorize the file operations.

Return value

array Nested array of information about FileTransfer classes. Each key is a FileTransfer type (not human readable, used for form elements and variable names, etc), and the values are subarrays that define properties of that type. The keys in each subarray are:

  • 'title': Required. The human-readable name of the connection type.
  • 'class': Required. The name of the FileTransfer class. The constructor will always be passed the full path to the root of the site that should be used to restrict where file transfer operations can occur (the $jail) and an array of settings values returned by the settings form.
  • 'file': Required. The include file containing the FileTransfer class. This should be a separate .inc file, not just the .module file, so that the minimum possible code is loaded when authorize.php is running.
  • 'file path': Optional. The directory (relative to the Drupal root) where the include file lives. If not defined, defaults to the base directory of the module implementing the hook.
  • 'weight': Optional. Integer weight used for sorting connection types on the authorize.php form.

See also

FileTransfer

authorize.php

hook_filetransfer_info_alter()

drupal_get_filetransfer_info()

Related topics

4 functions implement hook_filetransfer_info()

1 invocation of hook_filetransfer_info()

File

drupal/modules/system/system.api.php, line 4428
Hooks provided by Drupal core and the System module.

Code

function hook_filetransfer_info() {
  $info['sftp'] = array(
    'title' => t('SFTP (Secure FTP)'), 
    'file' => 'sftp.filetransfer.inc', 
    'class' => 'FileTransferSFTP', 
    'weight' => 10,
  );
  return $info;
}