Whenever I attempt to use file upload, I get the following error:

Exception: Resource is not a file or it is an empty directory: in FeedsFileFetcher->fetch() (line 67 of feeds/plugins/FeedsFileFetcher.inc).

the line is:
throw new Exception(t('Resource is not a file or it is an empty directory: %source', array('%source' => $source_config['source'])));

the array result is:
[FeedsFileFetcher] => Array ( [fid] => [source] => [upload] => )

Comments

SocialNicheGuru’s picture

Status: Active » Closed (duplicate)

caused by patch here: https://drupal.org/node/1127696

GuyPaddock’s picture

Issue summary: View changes
Priority: Normal » Critical
Status: Closed (duplicate) » Active

@SocialNicheGuru: Your comment literally makes no sense. I've reviewed the other issue and there's nothing to indicate they're related.

I'm seeing this issue when running the latest version of Feeds on Acquia Dev Desktop. I have verified that the File Fetcher settings and Drupal File system settings are configured correctly.

This issue completely blocks the ability to do CSV imports.

Here's an export of my importer:

$feeds_importer = new stdClass();
$feeds_importer->disabled = FALSE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'contractor_profile_csv';
$feeds_importer->config = array(
  'name' => 'Contractor Profile CSV',
  'description' => 'Imports new contractor user accounts / user profiles from a CSV file.',
  'fetcher' => array(
    'plugin_key' => 'FeedsFileFetcher',
    'config' => array(
      'allowed_extensions' => 'txt csv tsv xml opml',
      'direct' => 0,
      'directory' => 'public://feeds/contractor_profile',
      'allowed_schemes' => array(
        'public' => 'public',
      ),
    ),
  ),
  'parser' => array(
    'plugin_key' => 'FeedsCSVParser',
    'config' => array(
      'delimiter' => ',',
      'no_headers' => 0,
    ),
  ),
  'processor' => array(
    'plugin_key' => 'FeedsUserProcessor',
    'config' => array(
      'roles' => array(
        104169657 => '104169657',
        30037204 => 0,
        211406981 => 0,
        245154260 => 0,
        4142765 => 0,
        79959846 => 0,
        162103589 => 0,
        160177598 => 0,
        259479786 => 0,
        263062362 => 0,
        244667557 => 0,
        238777296 => 0,
        110079917 => 0,
        76210658 => 0,
        49578983 => 0,
        191345237 => 0,
        58046434 => 0,
        219102880 => 0,
        6462655 => 0,
        235880667 => 0,
        199746617 => 0,
        59661863 => 0,
        60039842 => 0,
        92489976 => 0,
        262615644 => 0,
        190827355 => 0,
      ),
      'status' => '1',
      'defuse_mail' => 0,
      'mappings' => array(
        0 => array(
          'source' => 'User UUID (Optional)',
          'target' => 'guid',
          'unique' => 0,
        ),
        1 => array(
          'source' => 'User e-mail address',
          'target' => 'mail',
          'unique' => 1,
        ),
        2 => array(
          'source' => 'User name',
          'target' => 'name',
          'unique' => FALSE,
        ),
        3 => array(
          'source' => 'Business name',
          'target' => 'profile2:contractor:field_contractor_business_name',
          'unique' => FALSE,
        ),
        4 => array(
          'source' => 'Business logo (URL, optional)',
          'target' => 'profile2:contractor:field_contractor_logo',
          'unique' => FALSE,
        ),
        5 => array(
          'source' => 'Business address - line #1',
          'target' => 'profile2_address_field:contractor:field_contractor_address:thoroughfare',
          'unique' => FALSE,
        ),
        6 => array(
          'source' => 'Business address - line #2 (optional)',
          'target' => 'profile2_address_field:contractor:field_contractor_address:premise',
          'unique' => FALSE,
        ),
        7 => array(
          'source' => 'Business address - city',
          'target' => 'profile2_address_field:contractor:field_contractor_address:locality',
          'unique' => FALSE,
        ),
        8 => array(
          'source' => 'Business address - state',
          'target' => 'profile2_address_field:contractor:field_contractor_address:administrative_area',
          'unique' => FALSE,
        ),
        9 => array(
          'source' => 'Business address - zip',
          'target' => 'profile2_address_field:contractor:field_contractor_address:postal_code',
          'unique' => FALSE,
        ),
        10 => array(
          'source' => 'Business address - country (optional)',
          'target' => 'profile2_address_field:contractor:field_contractor_address:country',
          'unique' => FALSE,
        ),
        11 => array(
          'source' => 'Specialties (Comma-separated)',
          'target' => 'profile2:contractor:field_contractor_specialties',
          'unique' => FALSE,
        ),
        12 => array(
          'source' => 'Phone number',
          'target' => 'profile2:contractor:field_contractor_phone',
          'unique' => FALSE,
        ),
      ),
      'update_existing' => '0',
      'update_non_existent' => 'skip',
      'input_format' => 'plain_text',
      'skip_hash_check' => 0,
      'bundle' => 'user',
    ),
  ),
  'content_type' => '',
  'update' => 0,
  'import_period' => '-1',
  'expire_period' => 3600,
  'import_on_create' => 1,
  'process_in_background' => 0,
);

MegaChriz’s picture

Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

@GuyPaddock
I tried your importer, got a lot of missing targets (even after installing profile2 module and adding fields to a profile entity) so I removed these. Then downloaded the CSV template, added an item to it and imported that. Result: "Created 1 user."

Can it be that the file permissions of the folder are not correct? If they are correct, can you provide the steps to reproduce the issue? Now it looks like something related to profile2 is involved.

qpro’s picture

Similar here (debian 8.3, drupal 7.43, Feeds 7.x-2.0-beta2),

I am able to import a file indicating file name (public://feeds/filename.xml), but If I don't set the file name (public://feeds/ or public://feeds) I get "Resource is not a file or it is an empty directory"

MegaChriz’s picture

@qpro
I tried to reproduce your issue this way:

  1. Created an importer with fetcher "File upload", parser "CSV parser" and processor "Node processor".
  2. On the setting for "File upload" enabled option "Supply path to file or directory directly."
  3. Configured processor, selected a bundle and configured a few mappings (title, body, published and guid).
  4. In the files directory, created a directory called "import". Added one CSV file with a single item to this directory.
  5. Went to the import page, set "File" to "public://import".

Result: Created 1 node.

Can you provide the full steps to reproduce the issue? Also, it seems your settings are different from what is reported in #2 where the option "Supply path to file or directory directly." was not enabled.

If the issue occurs even if you keep the importer settings as much to the defaults as possible, try if you can reproduce the issue on a fresh install.

qpro’s picture

Ok , in my case it's solved:

"Allowed file extensions" (in "File upload Settings") is case sensitive.

I had added "xml" but our vendor files has "XML" extension, so the solution is to add XML (uppercase) to "Allowed file extensions" or rename all files extensions to xml (lowercase).

Thanks for your time reproduccing the issue, it makes me realize about the true problem.

MegaChriz’s picture

@qpro
Ah, then your issue is probably different than the original issue here. The check for allowed file extensions when supplying a directory of files is new since 7.x-2.0-beta2 (added after this issue was created). See #2309471: File Fetcher doesn't obey allowed extensions.

I think that the extension check should be case insensitive, though.

ann b’s picture

Same as #4. I'm getting the following errors after attempting to import a csv file:

Notice: Undefined property: stdClass::$uri in FeedsFileFetcher->sourceFormValidate() (line 151 of .../sites/all/modules/feeds/plugins/FeedsFileFetcher.inc).

Notice: Undefined property: stdClass::$uri in file_save() (line 603 of .../includes/file.inc).

Notice: Undefined property: stdClass::$uri in file_entity_file_presave() (line 14 of .../sites/all/modules/file_entity/file_entity.file.inc).

Resource is not a file or it is an empty directory:

*

Drupal 7.54
Feeds 7.x-2.0-beta3

*

But if I manually enter the path, then it worked ok.

private://feeds/test.csv

ericmulder1980’s picture

I am getting this issue on Drupal 7.56 with Feeds 7.x-2.0-beta3. Strange thing is that it works without issues when manually running the import in a browser and even when running it through drush feeds-import-all. When running it through the Job Scheduler i get the "Resource is not a file or it is an empty directory" issue.

nikita_tt’s picture

For @ericmulder1980 (comment #9) and future researchers. I faced the same issue. The problem was in the way how cron was run.
In my case it was triggered via drush every minute. Command: drush -l mysitealias -r /var/www/html cron. Because of the "-l mysitealias" option the real path of the file was built wrong.