You are here

file_service.module in Services 7

@author Services Dev Team

Link general file functionalities to services module.

File

services/file_service/file_service.module
View source
<?php

/**
 * @author Services Dev Team
 * @file
 *  Link general file functionalities to services module.
 */

/**
 * Implementation of hook_perm().
 */
function file_service_perm() {
  return array(
    'get any binary files',
    'get own binary files',
    'save file information',
  );
}

/**
 * Implementation of hook_service().
 */
function file_service_service() {
  return array(
    // file.get
    array(
      '#method' => 'file.get',
      '#callback' => 'file_service_get',
      '#access callback' => 'file_service_get_access',
      '#file' => array(
        'file' => 'inc',
        'module' => 'file_service',
      ),
      '#args' => array(
        array(
          '#name' => 'fid',
          '#type' => 'int',
          '#description' => t('A file ID.'),
        ),
      ),
      '#return' => 'array',
      '#help' => t('The file data.'),
    ),
    // file.getNodeFiles
    array(
      '#method' => 'file.getNodeFiles',
      '#callback' => 'file_service_get_node_files',
      '#access callback' => 'file_service_get_node_files_access',
      '#file' => array(
        'file' => 'inc',
        'module' => 'file_service',
      ),
      '#args' => array(
        array(
          '#name' => 'nid',
          '#type' => 'int',
          '#description' => t('A node ID.'),
        ),
      ),
      '#return' => 'array',
      '#help' => t('Returns the files attached to a node.'),
    ),
    // file.save
    array(
      '#method' => 'file.save',
      '#callback' => 'file_service_save',
      '#access arguments' => 'save file information',
      '#file' => array(
        'file' => 'inc',
        'module' => 'file_service',
      ),
      '#args' => array(
        array(
          '#name' => 'file',
          '#type' => 'struct',
          '#description' => t('An object representing a file.'),
        ),
      ),
      '#return' => 'int',
      '#help' => t('Saves information about a specific file. Note this does not save files themselves, just the information as stored in the files table. Returns the fid of the new/updated file.'),
    ),
  );
}

Functions

Namesort descending Description
file_service_perm Implementation of hook_perm().
file_service_service Implementation of hook_service().