FlysystemBridge missing getDirectoryPath() method required by Drupal's FileSystem::tempnam()

Created on 11 August 2025, 3 months ago

Problem/Motivation

After upgrading to Flysystem 2.2.x, sites using remote stream wrappers (like S3) encounter fatal errors when Drupal tries to create temporary files:

Error: Call to undefined method Drupal\flysystem\FlysystemBridge::getDirectoryPath()

This error occurs because Drupal's FileSystem::tempnam() method expects all stream wrappers to implement a getDirectoryPath() method, but this method was not included in the FlysystemBridge class. The error is triggered when:

  • Image styles are generated for files stored on remote streams
  • Temporary files need to be created for remote file operations
  • File downloads are processed through Drupal's file system

Steps to reproduce

  1. Install Flysystem 2.2.x with a remote driver (e.g., S3)
  2. Configure a file field to use the remote scheme (e.g., s3://)
  3. Upload a file or try to generate an image style
  4. Observe the fatal error when Drupal calls getDirectoryPath() on the stream wrapper

Alternatively, reproduce with Drush:

drush eval "
\$wrapper = \Drupal::service('stream_wrapper_manager')->getViaUri('s3://test.jpg');
echo \$wrapper->getDirectoryPath();
"

Proposed resolution

Add the missing getDirectoryPath() method to the FlysystemBridge class. For remote streams, this method should return the system temporary directory path since remote streams don't have local directory paths.

🐛 Bug report
Status

Active

Version

2.2

Component

Code

Created by

🇪🇪Estonia tormi Tallinn

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024