- 🇬🇧United Kingdom nicrodgers Monmouthshire, UK
Patch applies successfully and works with and without stage_file_proxy
- Status changed to Needs work
over 1 year ago 10:49am 8 June 2023 - 🇪🇸Spain manuel.adan 🌌
-
+++ b/src/MimeDetectService.php @@ -87,10 +87,21 @@ class MimeDetectService implements MimeDetectServiceInterface { + if (\Drupal::moduleHandler()->moduleExists('stage_file_proxy')) { + $server = \Drupal::config('stage_file_proxy.settings')->get('origin'); + $fetch_manager = \Drupal::service('stage_file_proxy.fetch_manager');
Dependency injection → should be used here to make use of the module handler, config manager and Stage File Proxy fetch manager.
-
+++ b/src/MimeDetectService.php @@ -87,10 +87,21 @@ class MimeDetectService implements MimeDetectServiceInterface { + $file_path = implode('/', [$server, $file_dir, $relative_path]);
It seems that path to file is composed using the remote server name, which ends in a non local file path (eg.: http://www.example.com/sites/default/files/image.jpg). The following mime detection method (file UNIX command) is unable to manage remote URLs, it only works with local files, so the file itself should be retrieved.
I think that there is no point of checking remote files since they should be already checked on their environment. A better approach here would be just to skip non-local files.
-
- @nicrodgers opened merge request.
- Status changed to Needs review
about 1 year ago 10:35am 31 August 2023 - 🇬🇧United Kingdom nicrodgers Monmouthshire, UK
I think that there is no point of checking remote files since they should be already checked on their environment. A better approach here would be just to skip non-local files.
Good point. I've taken this approach, by skipping remote files in hook_file_validate.
Hiding the patches, latest code is in the MR.