Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uri_prefix don't handle absolute directory_namer #1378

Open
mysterty opened this issue Mar 30, 2023 · 0 comments
Open

uri_prefix don't handle absolute directory_namer #1378

mysterty opened this issue Mar 30, 2023 · 0 comments

Comments

@mysterty
Copy link

mysterty commented Mar 30, 2023

Bug Report

Q A
BC Break no
Bundle version 2.1.1
Symfony version 6.1.12
PHP version 8.2.4

Summary

uri_prefix add an unwished "/" in the beginning of files' url if directory namer already begin with a "/".

Current behavior

Using directory_namer, uri_prefix add a "/" in beginning, resulting to something like //path/to/file.jpg and is wrong (like in vich uploader field in form). Need to set uri_prefix to 'uploads/..' to prevent it or change the directory namer to send a string not beginning by a "/"

How to reproduce

use directory_namer :

vich_uploader:
  db_driver: orm
  storage: flysystem

  mappings:
    media:
      uri_prefix: '' # 'uploads/..' is a working temp fix
      upload_destination: oneup_flysystem.default_filesystem_filesystem
      namer: Vich\UploaderBundle\Naming\SmartUniqueNamer
      directory_namer:
        service: vich_uploader.namer_directory_property
        options: { property: "directory", transliterate: false }
// Entity\Media.php
class Media
{
	private ?string $directory = '/uploads/medias/';
	[...]
	// ##################### Custom methods #####################

	public function getDirectory(): ?string
	{
		return $this->directory;
	}
}

Expected behavior

Default uri_prefix should handle if directory namer already begins by a "/".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants