Support the ongoing development of Laravel.io →
Requests Packages

I have the following action in my repository:

 public function getAsset($filename, $prefix = null, $directory = null)
    {

        if($directory) $directory = $directory;

        $file = $directory . $prefix . $filename;

        if($file) return $file;

        return false;

    }

This method will be responsible for returning a URL to an asset for use within my app. How can I easily build this URL? Does Flysystem come with a method for this? Checked the documentation and couldn't find anything.

The app user will have the ability to change the Filesystem on the fly via a settings panel, currently between Local & S3 and I would like the system to build the URL depending on what setting is set (I am using a custom settings module to inject the default into the Flysystem's config. This is working fine.

The paths will be as follows: local: storage/media/xxxx.jpg s3: bucketname/media/xxxx.jpg

Thanks in advance for any help.

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.