I’m trying to connect my Laravel application to a Storj.io bucket for file uploads using Laravel’s built-in storage system (Storage::disk()), similar to how I would connect to AWS S3. However, I haven’t been able to get it working, and I’m stuck.
Here’s what I’ve done so far:
1. Environment Configuration:
I added the following details to my .env file:
AWS_ACCESS_KEY_ID=my_access_key
AWS_SECRET_ACCESS_KEY=my_secret_key
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=my_storj_bucket
AWS_ENDPOINT=https://gateway.storjshare.io
AWS_USE_PATH_STYLE_ENDPOINT=true
I updated the s3 driver in config/filesystems.php
:
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
],
I wrote a simple file upload function:
$path = $request->file('file')->store('uploads', 's3');