Help for integrating the Laravel package
Forum rules: Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#2081 by swpierce
24 Nov 2015, 14:23
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!
#2090 by swpierce
24 Nov 2015, 22:59
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!
#2098 by aimeos
25 Nov 2015, 11:15
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/blob/master/controller/extjs/src/Controller/ExtJS/Media/Standard.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?
#2114 by aimeos
27 Nov 2015, 14:57
We created a thin file system layer modeled after POSIX/Flysystem in the development version:
https://github.com/aimeos/aimeos-core/tree/master/lib/mwlib/src/MW/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/Core/client/html/common/content/baseurl)