Laravel-medialibrary: Custom headers not for conversions

Created on 5 Dec 2017  Â·  10Comments  Â·  Source: spatie/laravel-medialibrary

Hey @freekmurze,

i realized that the custom headers is used only for the main file but not for the conversions.
I want to set a file to public read on Amazon S3. This worked for the main file, but the conversions are still private.

Example code:

$model->addMedia($file)
    ->addCustomHeaders([
        'ACL' => 'public-read'
    ])
    ->toMediaCollection($type);

Most helpful comment

Will be fixed in #971

All 10 comments

I’ll try to take care of this soon.

If you need this fixed quickly, feel free to submit a PR.

On Tue, 5 Dec 2017 at 23:17, Heiko Klingele notifications@github.com
wrote:

Hey @freekmurze https://github.com/freekmurze,

i realized that the custom headers is used only for the main file but not
for the conversions.
I want to set a file to public read on Amazon S3. This worked for the main
file, but the conversions are still private.

Example code:

$model->addMedia($file) ->addCustomHeaders([ 'ACL' => 'public-read' ]) ->toMediaCollection($type);

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/spatie/laravel-medialibrary/issues/868, or mute the
thread
https://github.com/notifications/unsubscribe-auth/AAdiDY9ag__kpEnoeGXtN-iY5uQ8LXLeks5s9cEUgaJpZM4Q3DY9
.

>

Freek Van der Herten https://spatie.be +32 495 84 27 91

@divdax @freekmurze any news about this? exist another way to put acl public in conversions?

Couldn't you set a policy on the bucket itself that fixes this?

No, because i have some files public and other private

I also have a private bucket and need to set acl public via header. In my case a user can upload files and make them public (optional) via interface. An aws bucket policy can't do that.

@omacesc Am I correct in assuming that if you make the conversion in your model non queued, the headers are passed correctly?

You can do this by calling ->nonQueued() in registerMediaConversions:

public function registerMediaConversions(Media $media = null)
{
    $this->addMediaConversion('thumb')
        ->nonQueued();
}

@brendt thanks for you answer, but i tried and doesn't work :(

in controller:

$model->addMedia($request->image)->addCustomHeaders([
                    'ACL' => 'public-read'
                ])->toMediaCollection($type,'s3');

in model:

$this->addMediaConversion('thumb')
            ->fit(Manipulations::FIT_FILL, 500, 120)
            ->nonQueued();

Thanks for trying it out. We'll look further into this.

Will be fixed in #971

Was this page helpful?
0 / 5 - 0 ratings

Related issues

swash13 picture swash13  Â·  3Comments

brendt picture brendt  Â·  4Comments

jam1e picture jam1e  Â·  3Comments

mohammad6006 picture mohammad6006  Â·  4Comments

drtheuns picture drtheuns  Â·  3Comments