Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
$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
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:
Comments
Comment #2
marcingy CreditAttribution: marcingy as a volunteer commentedComment #3
jcnventura CreditAttribution: jcnventura at 1xINTERNET commentedComment #7
Shreya_th CreditAttribution: Shreya_th at Virasat Solutions commentedHi @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.
Comment #8
tyler.frankenstein CreditAttribution: tyler.frankenstein commentedThank you, @Shreya_h.
> What is the purpose of drupal_realpath() here?
From looking at the docs for drupal_realpath():
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:
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.