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

Allow creating directory subfolders by giving the path in the config #1427

Merged

Conversation

syffer
Copy link
Contributor

@syffer syffer commented Feb 5, 2024


name: ⚙ Improvement
about: Allowing to set the image subfolders directly from the yaml configuration (without having to rely on property accessor)

Improvement

Q A
New Feature yes
RFC no
BC Break no

Summary

This pr is a proposal to add a new directory namer, which allow to configure the image subfolders directly from the yaml configuration.

This would allow to use multiple vich mapping on the same storage, without

  • having to duplicate the storage configuration for each mapping
  • be forced to use the PropertyDirectoryNamer, which add a method solely for this purpose

For example, it would allow to do the following:

vich_uploader:
    # ...

    storage: flysystem

    mappings:
        logo:
            uri_prefix: '%app.uploads.uri_prefix%'
            upload_destination: storage.uploads.cdn
            directory_namer:
                service: vich.namer_directory_configurable
                options:
                    directory_path: custom/logos
            namer:
                service: Vich\UploaderBundle\Naming\SmartUniqueNamer

        map:
            uri_prefix: '%app.uploads.uri_prefix%'
            upload_destination: storage.uploads.cdn
            directory_namer:
                service: vich.namer_directory_configurable
                options:
                    directory_path: custom/maps
            namer:
                service: Vich\UploaderBundle\Naming\SmartUniqueNamer

flysystem:
    storages:
        storage.uploads.cdn:
            adapter: 'gcloud'
            visibility: !php/const League\Flysystem\GoogleCloudStorage\PortableVisibilityHandler::NO_PREDEFINED_VISIBILITY
            options:
                client: 'app.uploads_cdn.gcloud_client_service'
                bucket: '%uploads.cdn.gcp.storage.bucket_name%'
                prefix: '%uploads.cdn.gcp.storage.path_prefix%'

This would also take care of #1377

@syffer syffer force-pushed the directory-namer/configurable-path-from-yaml branch 3 times, most recently from 128949f to 2946e03 Compare February 6, 2024 08:28
@syffer syffer force-pushed the directory-namer/configurable-path-from-yaml branch from 2946e03 to bf359c5 Compare February 6, 2024 08:30
@garak garak merged commit c053523 into dustin10:master Jun 11, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants