Skip to content

Can't generate temporary URL using InMemoryFilesystemAdapter #287

@juanwilde

Description

@juanwilde

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",
  • Create a test extending KernelTestCase
  • Create a class or use case that calls League\Flysystem\Filesystem::temporaryUrl
  • It will throw League\Flysystem\UnableToGenerateTemporaryUrl: "Unable to generate temporary url for 7f736383-dcb8-47db-bd17-888b75ac9481/export_2023-09-18_09-29-05.xlsx: No generator was configured "

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions