public function FeedsEnclosure::getFile

cis7 public FeedsEnclosure::getFile($destination)
cle7 public FeedsEnclosure::getFile($destination)
elmsmedia7 public FeedsEnclosure::getFile($destination)
icor7 public FeedsEnclosure::getFile($destination)
meedjum_blog7 public FeedsEnclosure::getFile($destination)
mooc7 public FeedsEnclosure::getFile($destination)

Get a Drupal file object of the enclosed resource, download if necessary.


$destination: The path or uri specifying the target directory in which the file is expected. Don't use trailing slashes unless it's a streamwrapper scheme.

Return value

A Drupal temporary file object of the enclosed resource.


Exception If file object could not be created.


sites/all/modules/ulmus/feeds/plugins/, line 335
Contains FeedsParser and related classes.


Enclosure element, can be part of the result array.


public function getFile($destination) {

  if ($this->getValue()) {
    // Prepare destination directory.
    file_prepare_directory($destination, FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY);
    // Copy or save file depending on whether it is remote or local.
    if (drupal_realpath($this->getValue())) {
      $file = new stdClass();
      $file->uid = 0;
      $file->uri = $this->getValue();
      $file->filemime = $this->mime_type;
      $file->filename = basename($file->uri);
      if (dirname($file->uri) != $destination) {
        $file = file_copy($file, $destination);
      else {
        // If file is not to be copied, check whether file already exists,
        // as file_save() won't do that for us (compare file_copy() and
        // file_save())
        $existing_files = file_load_multiple(array(), array('uri' => $file->uri));
        if (count($existing_files)) {
          $existing = reset($existing_files);
          $file->fid = $existing->fid;
          $file->filename = $existing->filename;
    else {
      $filename = basename($this->getLocalValue());
      if (module_exists('transliteration')) {
        require_once drupal_get_path('module', 'transliteration') . '/';
        $filename = transliteration_clean_filename($filename);
      if (file_uri_target($destination)) {
        $destination = trim($destination, '/') . '/';
      try {
        $file = file_save_data($this->getContent(), $destination . $filename);
      catch (Exception $e) {
        watchdog_exception('Feeds', $e, nl2br(check_plain($e)));

    // We couldn't make sense of this enclosure, throw an exception.
    if (!$file) {
      throw new Exception(t('Invalid enclosure %enclosure', array('%enclosure' => $this->getValue())));
  return $file;



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.