Page 1 of 1

Storing images, etc. on Amazon S3

Posted: 24 Nov 2015, 14:23
by swpierce
We're going to be storing our product images on Amazon S3. Just wanted to make sure that I don't need to do anything specific for Aimeos to work with S3. All I need to do is configure the Laravel filesystem provider and all will be well?

Thanks!

Re: Storing images, etc. on Amazon S3

Posted: 24 Nov 2015, 17:45
by aimeos
Almost :-)

You have to tell Aimeos to use your Amazon S3 URL as base URL:
https://aimeos.org/docs/Laravel/Optimiz ... atic_files

Re: Storing images, etc. on Amazon S3

Posted: 24 Nov 2015, 22:59
by swpierce
Almost! :D

Missing one part.

When someone is creating a product via the admin interface and needs to upload an image for that product, we want the image to get stored in the S3 bucket - not in the uploads directory.

Pulling images from S3 is simple enough - just put the full URL in the mshop_media file. Works great.

my filesystem.php has:

Code: Select all

    's3' => [
            'driver' => 's3',
            'key'    => env('AWS_KEY'),
            'secret' => env('AWS_SECRET'),
            'region' => env('AWS_REGION'),
            'bucket' => env('AWS_BUCKET'),
        ],
my .env file is set up correctly with the above settings.

my config/shop.php includes:

Code: Select all

			'common' => array(
				'content' => array(
					'baseurl' => 'https://s3-us-west-2.amazonaws.com/bucketname/',
				),
I'm guessing, looking at the AdminController in the aimeos-laravel tree, that since this line exists:

Code: Select all

'uploaddir' => \Config::get( 'shop::uploaddir' ),
that it won't be as easy as trying to find a Storage::disk('local') and replace it with a Storage::disk('s3')

Can you point me in the right direction to override the media upload behavior in the admin side such that I don't break anything critical? :P

Thanks!

Re: Storing images, etc. on Amazon S3

Posted: 25 Nov 2015, 11:15
by aimeos
swpierce wrote: Can you point me in the right direction to override the media upload behavior in the admin side such that I don't break anything critical? :P
OK, that's currently a weak part of Aimeos. Files uploaded by the ExtJS admin interface are stored only locally. To change that, you have to use the Flysystem calls in https://github.com/aimeos/aimeos-core/b ... andard.php.

That's an improvement we need to add to the Aimeos Core. Are you able to open a pull request on Github with the necessary changes?

Re: Storing images, etc. on Amazon S3

Posted: 25 Nov 2015, 12:46
by swpierce
I'll work on that this weekend and see what I can do :)

Re: Storing images, etc. on Amazon S3

Posted: 27 Nov 2015, 14:57
by aimeos
We created a thin file system layer modeled after POSIX/Flysystem in the development version:
https://github.com/aimeos/aimeos-core/t ... Filesystem

The integration into the Laravel package is completed too, so it's possible now to use that file system layer to store and retrieve files from every supported (cloud) storage within the Aimeos library. It will use the configured default storage from the Laravel applications.

BTW: It's better to store only the relative paths in the media items because all paths in the storage are also relative. Furthermore, it's a lot easier to switch to a different cloud service if you only have to change the configuration (https://aimeos.org/docs/Configuration/C ... nt/baseurl)

Re: Storing images, etc. on Amazon S3

Posted: 27 Nov 2015, 19:25
by swpierce
Awesome! I'll pull it down and see if I can get it working.

Thanks!!