Fiton012's avatar

Spatie media library upload to Amazon s3 bucket subfolder

I am using spatie media library in Laravel with the below code to upload images to s3 bucket

$file = $this->fileUploadModel
             ->addMediaFromDisk($file->path(), 's3')
             ->toMediaCollection();

The image is saved to s3 bucket on the format:

  • my_bucket_name/1/image_name.png
  • my_bucket_name/2/image_name.png etc

However I want a way to store the images inside an images folder ie.

my_bucket_name/images/1/image_name.png

By using only Laravel you can do that with a simple:

$file->store('images','s3');

How can I do that in spatie library?

0 likes
1 reply

Please or to participate in this conversation.