Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel: Use Linode's Storage Object as an alternative to AWS S3

Linode's Object Storage is marked as being S3 compatible. Knowing this I thought that I can simply use Linode's credentials in my filesystems.php and use ->disk('s3') to upload and download files but apparently this is not the case.

I have installed all required S3 PHP packages as suggested in Laravel's docs.

My .env has:

AWS_ACCESS_KEY_ID=foo
AWS_SECRET_ACCESS_KEY=bar
AWS_DEFAULT_REGION=DE
AWS_BUCKET=my-linode-storage-object.eu-central-1.linodeobjects.com

In logs I get exception to Could not resolve host. It tries to concatenate AWS endpoint with what I provided above so no-brainer that it doesn't work. Should I install completely different package to handle Linode's Storage Object connections?

I don't see much tutorials on the web on how to use Linode's Storage Object in Laravel apps. Any links or hints would be appreciated.

like image 549
Matt Komarnicki Avatar asked Apr 24 '20 11:04

Matt Komarnicki


People also ask

Is MinIO same as S3?

MinIO is a high-performance, object storage server designed for AI and ML workloads. It is fully compatible with the Amazon S3 API. Machine learning, big-data analytics, and other AI workloads have traditionally utilized the map-reduce model of computing where data is local to the compute jobs.

Is S3 same as object storage?

Amazon S3 is an object storage service that stores data as objects within buckets. An object is a file and any metadata that describes the file. A bucket is a container for objects.

Can we use S3 API for Onprem storage?

Applications that use the S3 API can more easily migrate between on-premise, private clouds built on Red Hat Ceph Storage and public clouds like AWS just by changing the storage endpoint network address.

What is S3 compatible object storage?

S3-Compatible Object Storage, or S3 is a storage solution that uses the S3 API. Data management and access to data is through an S3 compliant interface. The Spaces API aims to be interoperable with Amazon's AWS S3 API.


1 Answers

From the laravel docs just install one of the required Composer Packages

$ composer require league/flysystem-aws-s3-v3

Do not install league/flysystem-cached-adapter yet, since that would require more configuration.

Next, add a new disk that uses the s3 driver under the configuration filesytems file config/filesystems.php

'linode' => [
    'driver' => 's3',
    'key' => env('LINODE_KEY'),
    'secret' => env('LINODE_SECRET'),
    'endpoint' => env('LINODE_ENDPOINT'),
    'region' => env('LINODE_REGION'),
    'bucket' => env('LINODE_BUCKET'),
],

Add the new the environment variables to your project's .env file:

LINODE_KEY="KEYUNDERDOUBLEQUOTES"
LINODE_SECRET="SECRETUNDERDOUBLEQUOTES"
LINODE_ENDPOINT="https://eu-central-1.linodeobjects.com"
LINODE_REGION="eu-central-1"
LINODE_BUCKET="bucket-name"

I usually include the variables under "" to make sure it works with symbols. Also include http or https under LINODE_ENDPOINT.

Now that you have everything set up, you can now use this disk on your laravel code ->disk('linode')

like image 88
charlfields Avatar answered Sep 18 '22 09:09

charlfields