You are here

function node_export_file_get_export_data in Node export 6.3

Handles the file copying parts and local/remote parts of the file export.

Parameters

$file: The file object to handle.

$export_mode: The mode, 'inline' / 'local' / 'remote'

$assets_path: Either empty ('') if files should not be copied to the assets path, or the path to a writable directory.

1 call to node_export_file_get_export_data()
node_export_file_alter_filefield in modules/node_export_file/node_export_file.module
Abstract hook_node_export_node_alter() used by filefield, upload, and image.

File

modules/node_export_file/node_export_file.module, line 338
The Node export file module.

Code

function node_export_file_get_export_data($file, $export_mode, $assets_path) {
  if ($export_mode == 'local') {
    if ($assets_path) {
      $export_data = $assets_path . '/' . basename($file->filepath);
      if (!copy($file->filepath, $export_data)) {
        drupal_set_message(t("Export file error, could not copy '%filepath' to '%exportpath'.", array(
          '%filepath' => $file->filepath,
          '%exportpath' => $export_data,
        )), 'error');
        return FALSE;
      }
    }
    else {
      $export_data = $file->filepath;
    }
  }
  elseif ($export_mode == 'remote') {
    $export_data = url($file->filepath, array(
      'absolute' => TRUE,
    ));
  }
  else {
    $export_data = base64_encode(file_get_contents($file->filepath));
  }
  return $export_data;
}