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

How to set public visibility to each file for digitalocean spaces ? (s3 driver) #1018

Closed
netanelwebninja opened this issue Apr 3, 2018 · 10 comments

Comments

@netanelwebninja
Copy link

Hey,

I have Laravel 5.6 app, Im using digitalocean spaces for filesystem driver (its like s3, using same s3 driver for laravel).

I installed the laravel-medialibrary package, and upload files, works like a charm.

The problem is that all the files that uploaded to Digitalocean spaces are private, normally when I use laravel Storage facade I fix it using Storage:: setVisibility but I didnt found a way to do it with medialibrary.

I just want all the uploaded files to be visibility = public

Thanks

@thisiskaden
Copy link

Add visibility header in config file.

config/medialibrary.php

    'remote' => [
        /*
         * Any extra headers that should be included when uploading media to
         * a remote disk. Even though supported headers may vary between
         * different drivers, a sensible default has been provided.
         *
         * Supported by S3: CacheControl, Expires, StorageClass,
         * ServerSideEncryption, Metadata, ACL, ContentEncoding
         */
        'extra_headers' => [
            'CacheControl' => 'max-age=604800',
            'visibility' => 'public',
        ],
    ],

@netanelwebninja
Copy link
Author

@thisiskaden Thanks !

@lostlian
Copy link

lostlian commented Nov 25, 2018

@thisiskaden @netanelwebninja this worked for the main file. but conversion and responsive images still are still private.

how do you guys handle conversions and responsive images?

Update

Found the solution.

I was running jobs with horizon and after restart the horizon daemon it cached the proper headers. Looks like jobs cache the current state of the code and if any changes it wont be applied to jobs after restart the daemon

@dominikager
Copy link

Hi, i just migrated from S3 to Digitalocean. Now i have the problem that every asset is private.
Doest anybody has a solution?

@johnpuddephatt
Copy link

@dominikager I think you can set 'visibility' => 'public' in the config for your DO filesystem driver

@petsoukos
Copy link
Contributor

Add visibility header in config file.

config/medialibrary.php

    'remote' => [
        /*
         * Any extra headers that should be included when uploading media to
         * a remote disk. Even though supported headers may vary between
         * different drivers, a sensible default has been provided.
         *
         * Supported by S3: CacheControl, Expires, StorageClass,
         * ServerSideEncryption, Metadata, ACL, ContentEncoding
         */
        'extra_headers' => [
            'CacheControl' => 'max-age=604800',
            'visibility' => 'public',
        ],
    ],

Is there a way to set this per upload and not globally ?

@johnpuddephatt
Copy link

I haven't tested it but I think you need to add 'public' as a third parameter, as shown below:

$path = Storage::disk('s3')->put('directory_name/'.$user->id, $request->file('file_name'), 'public');

@petsoukos
Copy link
Contributor

I haven't tested it but I think you need to add 'public' as a third parameter, as shown below:

$path = Storage::disk('s3')->put('directory_name/'.$user->id, $request->file('file_name'), 'public');

But this doesn't use media library or I'm not getting it.

@johnpuddephatt
Copy link

johnpuddephatt commented Mar 30, 2021 via email

@chonchol-alzaf
Copy link

Add visibility header in config file.

config/medialibrary.php

    'remote' => [
        /*
         * Any extra headers that should be included when uploading media to
         * a remote disk. Even though supported headers may vary between
         * different drivers, a sensible default has been provided.
         *
         * Supported by S3: CacheControl, Expires, StorageClass,
         * ServerSideEncryption, Metadata, ACL, ContentEncoding
         */
        'extra_headers' => [
            'CacheControl' => 'max-age=604800',
            'visibility' => 'public',
        ],
    ],

thanks. its worked

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

7 participants