SAVE AS PDF
Lyve Cloud Object Storage Resources Guide 
Lyve Cloud Object Storage Resources Guide 

Was this content helpful?

Laravel is validated for use with Lyve Cloud Object Storage.

To add a Lyve Cloud storage in Laravel: 

  1. Install AWS S3 storage package using this command: 

composer require league/flysystem-aws-s3-v3

  1. Configure .env file, replacing items in <brackets> with the appropriate details related to your cloud: 
  • FILESYSTEM_DISK=s3
  • LYVE_ACCESS_KEY_ID=<access-key>
  • LYVE_SECRET_ACCESS_KEY=<secret-key>
  • LYVE_DEFAULT_REGION=<bucket-region>
  • LYVE_BUCKET=<bucket-name>
  • LYVE_ENDPOINT=<endpoint-url>
  • LYVE_USE_PATH_STYLE_ENDPOINT=true
  1. Configure Filesystem in Laravel by opening config/filesystems.php and ensuring the s3 disk configuration is set up correctly:
's3' => [ 'driver' => 's3',
    'key' => env('LYVE_ACCESS_KEY_ID'),
    'secret' => env('LYVE_SECRET_ACCESS_KEY'),
    'region' => env('LYVE_DEFAULT_REGION'),
    'bucket' => env('LYVE_BUCKET'),
    'endpoint' => env('LYVE_ENDPOINT'),
    'use_path_style_endpoint' => env('LYVE_USE_PATH_STYLE_ENDPOINT', false),
],
  1. Clear the cache and test the configuration. Run the following commands to clear Laravel's config cache:
php artisan config:clear
php artisan cache:clear
php artisan config:cache
  1. Upload a File to S3 by creating a simple file upload route in routes/web.php:
use Illuminate\Http\Request; 
use Illuminate\Support\Facades\Storage; 

Route::get('/upload', function () {
    return view('upload'); 
}); 

Route::post('/upload', function (Request $request) { 
    $path = $request->file('file')->store('uploads', 's3');  
    $url = Storage::disk('s3')->url($path); 
    return "File uploaded successfully: <a href="$url">$url</a>&quot;; });
  1. List Files from S3:
Route::get('/files', function () { 
    $files = Storage::disk('s3')->allFiles(); 
    return response()->json($files); 
}); 
  1. Download a File from S3:
Route::get('/download/{filename}', function ($filename) { 
    return Storage::disk('s3')->download("uploads/$filename"); 
});