Skip to content

How to set s3 file acl to public-read after upload? #259

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

Closed
winds1983 opened this issue Aug 25, 2016 · 6 comments
Closed

How to set s3 file acl to public-read after upload? #259

winds1983 opened this issue Aug 25, 2016 · 6 comments

Comments

@winds1983
Copy link

Issue Type:
  • Bug Report
Bundle Version:

Master or exact version, i.e. 6.0.1

Summary:

Below settings are my config, but it cannot set s3 file ACL. in other words, I still get private ACL after upload file, how to set it? I use Flysystem aws v3

# FMElfinderBundle configuration
fm_elfinder:
    instances:
        default:
            locale: %locale% # defaults to current request locale
            editor: ckeditor # other options are tinymce, tinymce4, fm_tinymce, form, simple, custom
            #editor_template: custom template for your editor # default null
            path_prefix: ~ # for setting custom assets path prefix, useful for non vhost configurations, i.e. http://127.0.0.1/mysite/
            #fullscreen: true|false # default is true, applies to simple and ckeditor editors
            #theme: smoothness # jquery theme, default is 'smoothness'
            include_assets: true # disable if you want to manage loading of javascript and css assets manually
            #visible_mime_types: ['image/png', 'image/jpg', 'image/jpeg'] # only show these mime types, defaults to show all
            connector:
                #debug: true|false # defaults to false
                roots:       # at least one root must be defined, defines root filemanager directories
                    aws_s3:
                        driver: Flysystem
                        url: %aws_s3_base_url%%aws_s3_bucket_name%
                        flysystem:
                            type: aws_s3_v3
                            options:
                                aws_s3_v3:
                                    version: %aws_sdk_version%
                                    key: %aws_access_key_id%
                                    secret: %aws_secret_access_key%
                                    region: %aws_s3_region%
                                    bucket_name: %aws_s3_bucket_name%
                        upload_allow: ["image/png", "image/jpg", "image/jpeg", "application/mp4", "video/mp4", "application/pdf", "application/x-pdf"]
                        upload_deny: ['all']
                        upload_max_size: 20M
        form:
            locale: %locale% # defaults to current request locale
            editor: form # other options are tinymce, tinymce4, fm_tinymce, form, simple, custom
            #editor_template: custom template for your editor # default null
            path_prefix: ~ # for setting custom assets path prefix, useful for non vhost configurations, i.e. http://127.0.0.1/mysite/
            #fullscreen: true|false # default is true, applies to simple and ckeditor editors
            #theme: smoothness # jquery theme, default is 'smoothness'
            include_assets: true # disable if you want to manage loading of javascript and css assets manually
            #visible_mime_types: ['image/png', 'image/jpg', 'image/jpeg'] # only show these mime types, defaults to show all
            connector:
                #debug: true|false # defaults to false
                roots:       # at least one root must be defined, defines root filemanager directories
                    aws_s3:
                        driver: Flysystem
                        url: %aws_s3_base_url%%aws_s3_bucket_name%
                        flysystem:
                            type: aws_s3_v3
                            options:
                                aws_s3_v3:
                                    version: %aws_sdk_version%
                                    key: %aws_access_key_id%
                                    secret: %aws_secret_access_key%
                                    region: %aws_s3_region%
                                    bucket_name: %aws_s3_bucket_name%
                        upload_allow: ["image/png", "image/jpg", "image/jpeg", "application/mp4", "video/mp4", "application/pdf", "application/x-pdf"]
                        upload_deny: ['all']
                        upload_max_size: 20M
@helios-ag
Copy link
Owner

Hi @winds1983, You can override Configuration reader class, and replace
L219,

$filesystem = new Filesystem(new AwsS3v3($client, $opt['aws_s3_v3']['bucket_name'], $opt['aws_s3_v3']['optional_prefix']));

with something like this

$filesystem = new Filesystem(new AwsS3v3($client, $opt['aws_s3_v3']['bucket_name'], $opt['aws_s3_v3']['optional_prefix']), [
    'visibility' => AdapterInterface::VISIBILITY_PRIVATE
]);

More information here: Global visibility setting

@winds1983
Copy link
Author

@helios-ag ok, thanks, I will try this.

@helios-ag
Copy link
Owner

@winds1983 if it will work for you, this feature can be implemented into bundle.

@benschumi
Copy link

@helios-ag Hi, i have the same issue, so i try to change ElFinderConfigurationReader.php

$filesystem = new Filesystem(new AwsS3v3($client, $opt['aws_s3_v3']['bucket_name'], $opt['aws_s3_v3']['optional_prefix']), [
    'visibility' => AdapterInterface::VISIBILITY_PUBLIC
]);

With that, my uploaded objects are public.
Can you implement this, maybe with a configuration to let the choice between public and private ?

@ofriedrich
Copy link

The workaround does not work, if caching is on. Turn off flysystems filesystem cache to make it work.

See barryvdh/elfinder-flysystem-driver#73

Tested with version 9.1

@therosco
Copy link
Contributor

Please have a look at #365

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

No branches or pull requests

5 participants