Laravel Vapor upload to DO Spaces

212 Views Asked by At

I want to use Laravel Vapor on my application. There's documentation on how to upload files to S3 using Vapor but none using other cloud providers. Is it possible to upload files to Digital Ocean's Spaces using vapor? If so does anyone have some sample code I could look at

1

There are 1 best solutions below

0
On

Here's a sample configuration for some "attachments" filesystem on DigitalOcean (its considered an "S3" service as well). I used it in a raw Laravel project but I expect Vapor to offer a very similar configuration file.

So in essence it should work out of the box if you give it the correct credentials:

// config/filesystems.php
'attachments' => [
    'driver' => env('ATTACHMENTS_DRIVER', 's3'),
    'root' => 'attachments/',
    'key' => env('DO_SPACES_KEY'),
    'secret' => env('DO_SPACES_SECRET'),
    'endpoint' => env('DO_SPACES_ENDPOINT'),
    'region' => env('DO_SPACES_REGION'),
    'bucket' => env('DO_SPACES_BUCKET'),
],

I added the DO_SPACES_xxx variables myself, you define them in your .env file, they should look similar to this:

DO_SPACES_KEY=5SOME4KEY3KRANDOMG
DO_SPACES_SECRET=12FABCI6D1MIz+Xep+321BC3MHcz+ABCO21
DO_SPACES_ENDPOINT=https://nyc3.digitaloceanspaces.com
# Region is empty in my configuration, not sure if you need it.
DO_SPACES_REGION=
DO_SPACES_BUCKET=yourbucketname