Asked  7 Months ago    Answers:  5   Viewed   35 times

I've been experimenting using the new Flysystem integration with Laravel 5. I am storing 'localised' paths to the DB, and getting the Storage facade to complete the path. For example I store screenshots/1.jpg and using




I can retrieve the same file on different disks.

get retrieves the file contents, but I am hoping to use it in my views like this:

<img src="{{ Storage::path('screenshots/1.jpg') }}" />

but path, or anything able to retrieve the full path is not available (as far as I can see). So how can I return the full path? Or, I'm wondering if this is by design? If so, why am I not supposed to be able to get the full path? Or, am I going about this completely the wrong way?



Edit: Solution for L5.2+

There's a better and more straightforward solution.

Use Storage::url($filename) to get the full path/URL of a given file. Note that you need to set S3 as your storage filesystem in config/filesystems.php: 'default' => 's3'

Of course, you can also do Storage::disk('s3')->url($filename) in the same way.

As you can see in config/filesystems.php there's also a parameter 'cloud' => 's3' defined, that refers to the Cloud filesystem. In case you want to mantain the storage folder in the local server but retrieve/store some files in the cloud use Storage::cloud(), which also has the same filesystem methods, i.e. Storage::cloud()->url($filename).

The Laravel documentation doesn't mention this method, but if you want to know more about it you can check its source code here.

Wednesday, March 31, 2021
answered 7 Months ago

I'm not sure what the correct way of doing this is with Flysystem, but the underlying S3Client object has a method for doing that. You could do $filesystem->getAdapter()->getClient()->getObjectUrl($bucket, $key);. Of course, building the URL is as trivial as you described, so you don't really need a special method to do it.

Wednesday, March 31, 2021
answered 7 Months ago

I solved this by getting an array of the column positions that I wanted to filter out. Then, by setting up a new CSV object to write to e.g.

$new = Writer::createFromFileObject(new SplTempFileObject);

With the CSV to read from, I used the each method to iterate through its rows, building a new row using the column indexes built earlier on and inserting into the new CSV. Remember to return true; in the each method or it won't iterate.

$csv = $csv->newReader();
$csv->each(function ($row) use ($new) {
    ... do stuff to alter the row ...
Friday, May 28, 2021
answered 5 Months ago

Are you talking about get parameter or something? If so, use:


For header you should use:


The working solution for this was the answer (the last one) of daver here: Laravel get request header

Saturday, May 29, 2021
answered 5 Months ago
public function handle(Request $request, Closure $next)
    $itemId = $request->item;

Saturday, May 29, 2021
answered 5 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :