-
Notifications
You must be signed in to change notification settings - Fork 517
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
Add possibility to specify upload directory when using storage #1377
Comments
Note : this can be accomplished with custom directory namer, and it can also be more friendly used in addition with liip imagine : vich_uploader:
db_driver: orm
storage: flysystem
mappings:
media:
uri_prefix: "/uploads/.."
upload_destination: oneup_flysystem.default_filesystem_filesystem ## oneup FlySystem
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 $basePath = '/uploads/medias/';
private ?string $directory = null;
[...]
// ##################### Custom methods #####################
public function getDirectory(): ?string
{
$date = $this->createdAt?$this->createdAt:date('Y-m-d H:i:s');
return $this->basePath.$date->format("Y").'/'.$date->format("m").'/';
}
public function getUrl(): ?string
{
return sprintf('%s/%s', $this->getDirectory(), $this->filename);
}
[...]
} Yet, it could be for some uses... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feature Request
Summary
Actually, using storage like flysystem, you need to make one storage configuration by mapping (+ one "default" for imagine if you use it) :
I propose to directly use
uri_prefix
as directory destination or add an optionaldirectory_destination
like :The text was updated successfully, but these errors were encountered: