You are here

public function FeedsImportBatch::getFilePath in Feeds 7

Same name and namespace in other branches
  1. 6 includes/FeedsBatch.inc \FeedsImportBatch::getFilePath()

Get a path to a temporary file containing the resource provided by the fetcher.

File will be deleted after DRUPAL_MAXIMUM_TEMP_FILE_AGE.

Return value

A path to a file containing the raw content as a source.

Throws

Exception If an unexpected problem occurred.

1 method overrides FeedsImportBatch::getFilePath()
FeedsFileBatch::getFilePath in plugins/FeedsFileFetcher.inc
Implements FeedsImportBatch::getFilePath().

File

includes/FeedsBatch.inc, line 196

Class

FeedsImportBatch
A FeedsImportBatch wraps the actual content retrieved from a FeedsSource. On import, it is created on the fetching stage and passed through the parsing and processing stage where it is normalized and consumed.

Code

public function getFilePath() {
  if (!isset($this->file_path)) {
    $destination = 'public://feeds';
    if (!file_prepare_directory($destination, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
      throw new Exception(t('Feeds directory either cannot be created or is not writable.'));
    }
    $this->file_path = FALSE;
    if ($file = file_save_data($this
      ->getRaw(), $destination . '/' . get_class($this) . REQUEST_TIME)) {
      $file->status = 0;
      file_save($file);
      $this->file_path = $file->uri;
    }
    else {
      throw new Exception(t('Cannot write content to %dest', array(
        '%dest' => $destination,
      )));
    }
  }
  return $this->file_path;
}