Asked  7 Months ago    Answers:  5   Viewed   31 times

I am trying to build a file management system in Laravel based on league/flysystem:

I am using the S3 adapter and I have it working to save the uploaded files using:

$filesystem->write('filename.txt', 'contents');

Now I am stuck on generating the download file URL when using the S3 adapter.

The files are saved correctly in the S3 bucket, I have permissions to access them, I just don't know how to get to the S3 getObjectUrl method through the league/flysystem package.

I have tried:

$contents = $filesystem->read('filename.txt');

but that returns the content of the file.

$contents = $filemanager->listContents();


$paths = $filemanager->listPaths();

but they give me the relative paths to my files.

What I need is something like "ht...//[s3-region][bucket]/[dir]/[file]..."



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

Just add them to the string.

return redirect()->away('');

The second parameter for this function is the http status that should be sent to the visitor. So when you add an array this is parsed as a 1.

Saturday, May 29, 2021
answered 5 Months ago

Similar issue happens in my local homestead development while my app running on Linode works fine.

After checking S3 permission, checked out old version, etc., this problem disappear when I restart homestead.

homestead halt
homestead up --provision
Saturday, May 29, 2021
answered 5 Months ago

Try to use the following:

Sunday, August 8, 2021
answered 3 Months ago

Set url to your cloudfront url in config/filesystems/s3

's3' => [
        'driver' => 's3',
        'key' => env('AWS_KEY'),
        'secret' => env('AWS_SECRET'),
        'region' => env('AWS_REGION'),
        'bucket' => env('AWS_BUCKET'),
        'url' => '']

It works in L5.5

Saturday, August 14, 2021
answered 2 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 :