Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

abzolute's avatar

How to retrieve a private file from S3 bucket in Flysystem 3.0

Before upgrading to Laravel 9 i did:

    $file = File::find(1);
	$s3Client = Storage::cloud()->getAdapter()->getClient();
    $stream = $s3Client->getObject([
        'Bucket' => config('filesystems.disks.s3.bucket'),
        'Key'    => $file->name
    ]);

    return response($stream['Body'], 200)->withHeaders([
        'Content-Type'        => $stream['ContentType'],
        'Content-Length'      => $stream['ContentLength'],
        'Content-Disposition' => 'inline; filename="' . $file->original_name . '"'
    ]);

I'm not sure how to adapt this to the new Flysystem 3.0 format.

Any assistance would be much appreciated.

0 likes
0 replies

Please or to participate in this conversation.