I got this error from the files module in a Drupal 9.3 website:

How to fix Error: Call to undefined method Drupal\Core\File\FileSystem::uriScheme()

Solution

The resolution was to replace the urlScheme call with

replace:

\Drupal::service('file_system')->uriScheme($uri);

with:

use Drupal\Core\StreamWrapper\StreamWrapperManager;
StreamWrapperManager::getScheme($uri);

 

Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!