Skip to content
Advertisement

Add Metadata, headers (Expires, CacheControl) to a file uploaded to Amazon S3 using the Laravel 5.0 Storage facade

I am trying to find out how to add in Metadata or headers (Expires, CacheControl etc.) to a file uploaded using the Laravel 5.0 Storage facade. I have use the page here as reference.

http://laravel.com/docs/5.0/filesystem

The following code works correctly:

JavaScript

After digging I also found that there is a ‘visibility’ parameter which sets the ACL to ‘public-read’ so the following also works correctly.

JavaScript

But I would like to be able to set some other values to the header of the file. I have tried the following:

JavaScript

Which doesn’t work, I have also tried:

JavaScript

But that creates an error where the ‘visibility’ parameter can not be converted from a string to an array. I have checked the source of AwsS3Adapter and it seems there is code for options but I can not seem to see how to pass them correctly. I think it takes the following:

JavaScript

Any help on how to accomplish this would be appreciated.

Advertisement

Answer

First, you need to call getDriver so you can send over an array of options. And then you need to send the options as an array.

So for your example:

JavaScript

Be aware that if you’re setting Cache-Control it has to be passed as CacheControl. This may well be true for other keys with non-alphanumierc characters.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement