Stolz / Assets

An ultra-simple-to-use assets management library for PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

S3 Support

sujitrulz opened this issue · comments

Hi @Stolz,
Is it possible to add files to s3 and fetch the file directly from s3 in blade file?

commented

If you are using the pipeline in theory it would be possible to retrieve the files from S3. If you take a look at the docs you'll see there is the fetch_command config option which accepts a closure that receives as first parameter the path of the asset to be pipelined. Simply add the logic for fetching files from S3 into that closure and make sure it returns the content of the asset.

For instance, assuming your Laravel S3 disk is properly configured:

// File: config/assets.php
return [
    /*...*/
    'fetch_command' = function ($asset) {
        return \Storage::disk('s3')->get($asset);
    },
    /*...*/
];