With the package Flysystem, we could easily access files stored in AWS S3
Config
edit the config file in /config/filesystems.php, change the AWS key pair accordingly
Installing Amazon S3 Driver
Before using the S3 storage, package has to be installed with composer
composer require league/flysystem-aws-s3-v3
Accessing Amazon S3 files
use Illuminate\Support\Facades\Storage;
$disk = Storage::disk('s3');
// store file into S3
$disk->put('images/1', $fileContents);
// check file exists?
$exists = $disk->exists('file.jpg');
// get file
$file = $disk->get('file.jpg');
// create a temp url
$url = $disk->temporaryURL('file.jpg', now()->addMinutes(5));
// get file size
$size = $disk->size('file.jpg');
// get last modified
$time = $disk->lastModified('file.jpg');
// delete file
$disk->delete('file.jpg');