1up-lab / OneupFlysystemBundle

A Flysystem integration for your Symfony projects.
MIT License
634 stars 118 forks source link

Can't generate temporary URL using InMemoryFilesystemAdapter #287

Open juanwilde opened 1 year ago

juanwilde commented 1 year ago

Bug Report

Q A
BC Break yes
Version 4.9.0

Summary

I am using the InMemoryFilesystemAdapter to test some parts of my application, so I added this configuration

// config/packages/test/filesystem.yaml

oneup_flysystem:
  filesystems:
    default_filesystem:
      adapter: memory_adapter
  adapters:
    memory_adapter:
      memory: ~

At some point in my use case I need to call a method to generate a temporary URL

$this->filesystem->temporaryUrl($path, $expirationDate);

Inside that method there is a condition to check if the generator is an instance of TemporaryUrlGenerator

    public function temporaryUrl(string $path, DateTimeInterface $expiresAt, array $config = []): string
    {
        $generator = $this->temporaryUrlGenerator ?: $this->adapter;

        if ($generator instanceof TemporaryUrlGenerator) {
            return $generator->temporaryUrl($path, $expiresAt, $this->config->extend($config));
        }

        throw UnableToGenerateTemporaryUrl::noGeneratorConfigured($path);
    }

And here is where it fails.

How to reproduce

In a Symfony 5.4 project install the following dependencies

"oneup/flysystem-bundle": "^4.8",
"league/flysystem-google-cloud-storage": "^3.15",
"league/flysystem-memory": "^3.0",