Laravel-medialibrary: How to set public visibility to each file for digitalocean spaces ? (s3 driver)

Created on 3 Apr 2018  路  3Comments  路  Source: spatie/laravel-medialibrary

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

Most helpful comment

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',
        ],
    ],

All 3 comments

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',
        ],
    ],

@thisiskaden Thanks !

@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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Krato picture Krato  路  4Comments

ideadx picture ideadx  路  4Comments

Radiergummi picture Radiergummi  路  4Comments

mohammad6006 picture mohammad6006  路  4Comments

denitsa-md picture denitsa-md  路  3Comments