Problem/Motivation
When attempting to use an external URL (e.g., ftp://example.com/file.txt) as the value for a file_url field, the following error is triggered:
Drupal\Core\File\Exception\InvalidStreamWrapperException in Drupal\Core\File\FileUrlGenerator->doGenerateString() (line 105 of core/lib/Drupal/Core/File/FileUrlGenerator.php).
This occurs because the FileUrlGenerator expects a supported stream wrapper (public://, private://, etc.) but does not recognize or handle external URL schemes like ftp://.
Steps to reproduce
- Create a field of type file_url.
- Add content with an external URL value, such as ftp://example.com/file.txt.
- Attempt to view the content.
- The error mentioned above is displayed.
Proposed resolution
Update the RemoteFile class to handle external URL schemes by implementing a createFileUrl() method. This method will return the file’s URI directly using getFileUri(), bypassing the unsupported stream wrapper logic.
Issue fork file_url-3490692
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
saidatomComment #4
saidatomComment #5
alorencComment #6
alorencLooks good, thanks
Comment #7
alorencComment #10
claudiu.cristeaThank you