dafdd64

  $file->file = base64_encode(file_get_contents(drupal_realpath($filepath))); 

What is the purpose of drupal_realpath() here? Reversing that commit fixed an issue for me with serving images from S3.

The error was:

Warning: file_get_contents(): Filename cannot be empty in _file_resource_retrieve() (line 268 of sites/all/modules/services/resources/file_resource.inc).

Issue fork services-2861617

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jacob.embree created an issue. See original summary.

marcingy’s picture

Version: 7.x-3.x-dev » 8.x-4.x-dev
jcnventura’s picture

Version: 8.x-4.x-dev » 7.x-3.x-dev

uttam made their first commit to this issue’s fork.

Shreya_th made their first commit to this issue’s fork.

Shreya_th’s picture

Hi @jcnventura,
We can modify the file_resource_retrieve() function to directly use the file URI without attempting to convert it to an absolute path. I made changes in the code and created MR . Kindly review the changes.

Thank you.

tyler.frankenstein’s picture

Thank you, @Shreya_h.

> What is the purpose of drupal_realpath() here?

From looking at the docs for drupal_realpath():

Resolves the absolute filepath of a local URI or filepath.

For example, an input of public://logo.png would return something like /sites/default/files/logo.png.

> Reversing that commit fixed an issue for me with serving images from S3.

Yeah, I see the docs mention:

it does not work for remote URIs.

I don't know if removing the call to drupal_realpath() would be safe for local URIs and I'd want to see/do some tests before committing.