Coder Social home page Coder Social logo

swagmedias3's Introduction

Amazon S3 Adapter for Shopware

https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square

The Amazon S3 adapter allows you to manage your media files in shopware on an Amazon S3 account. In addition, you can use Amazon CloudFront for delivering your files.

Building a package

Just run ./build.sh.

Install

Download the plugin from the release page and enable it in shopware.

Usage

Update your config.php in your root directory and fill in your own values:

'cdn' => [
    'backend' => 's3',
    'adapters' => [
        's3' => [
            'type' => 's3',
            'mediaUrl' => 'YOUR_S3_OR_CLOUDFRONT_ENDPOINT',
            'key' => 'YOUR_AWS_KEY',
            'secret' => 'YOUR_AWS_SECRET',
            'region' => 'YOUR_S3_REGION',
            'bucket' => 'YOUR_S3_BUCKET_NAME',
            'prefix' => ''
        ]
    ]
]

Using IAM roles in EC2

To make use of your configured IAM roles, omit the array keys key and secret or leave them empty. The plugin will retrieve the credentials from the EC2 metadata service automatically.

Value explanation

type (required)
Adapter type. Do not change.
mediaUrl (required)

URL to access your media files. Usually your S3, CloudFront or custom domain endpoint

e.g.: https://your-bucket-name.s3-website.eu-central-1.amazonaws.com/

region (required)
The S3 region, e.g. eu-central-1
bucket (required)
Your S3 bucket name
key
Your Access Key ID
secret
Your Secret Access Key
prefix
An optional path prefix for your media files
endpoint
Sets the S3 endpoint specifically (e.g. non-AWS S3)
metaOptions
Allows setting options per file specific to Flysystem S3 Adapter

License

The MIT License (MIT). Please see License File for more information.

swagmedias3's People

Contributors

bcremer avatar gerdner avatar janbuecker avatar larsfronius avatar lhwparis avatar mioduszewski avatar mitelg avatar shyim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swagmedias3's Issues

S3 Endpoint

What is meant with 'mediaUrl' => 'YOUR_S3_OR_CLOUDFRONT_ENDPOINT' - where to find it or how to set it - I have no clue what this means. Please update the Docu.

For easier installation, provide a Release with vendor files installed

This would help us until this is an official plugin in order for us to just be able to download the Release package. However, I don't know how this is done generally with shopware, so maybe I just miss a download page here. If so, could you please link me to the right place to get the plugin? Thanks! ๐Ÿ‘

PHP Fatal error: Uncaught TypeError: Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, string given

Servus,

version 2.0.0 will nicht mit Shopware 5.4.6 zusammen spielen.
Per "composer update" wurde Guzzle version 6.3.3 installiert

php error log nachfolgend


[29-Jul-2018 20:14:58 Europe/Berlin] PHP Fatal error: Uncaught TypeError: Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, string given, called in /pfad/zum/shop/httpdocs/custom/plugins/SwagMediaS3/vendor/guzzlehttp/guzzle/src/Client.php on line 89 and defined in /pfad/zum/shop/httpdocs/custom/plugins/SwagMediaS3/vendor/guzzlehttp/guzzle/src/Client.php:128
Stack trace:
#0 /pfad/zum/shop/httpdocs/custom/plugins/SwagMediaS3/vendor/guzzlehttp/guzzle/src/Client.php(89): GuzzleHttp\Client->request('setDefaultOptio...', 'verify', '/var/www/vhosts...')
#1 /pfad/zum/shop/httpdocs/engine/Shopware/Components/HttpClient/GuzzleFactory.php(43): GuzzleHttp\Client->__call('setDefaultOptio...', Array)
#2 /pfad/zum/shop/httpdocs/engine/Shopware/Components/HttpClient/GuzzleHttpClient.php(48): Shopware\Components\HttpClient\GuzzleFactory->createClient(Array)
#3 /pfad/zum/shop/httpdocs/var/cache/production_201807181357/proxies/ShopwareProduction14ca002122cedc8419e1085aec506909b8c098b7ProjectContainer.php(2407): Shopware\Components\HttpClient\GuzzleHttpClient->__construct(Object(Shopware\Components\HttpClient\GuzzleFactory), Array)
#4 /pfad/zum/shop/httpdocs/vendor/symfony/dependency-injection/Container.php(297): ShopwareProduction14ca002122cedc8419e1085aec506909b8c098b7ProjectContainer->getShopwarePlugininstaller_HttpClientService()
#5 /pfad/zum/shop/httpdocs/engine/Shopware/Components/DependencyInjection/Container.php(211): Symfony\Component\DependencyInjection\Container->get('shopware_plugin...', 1)
#6 /pfad/zum/shop/httpdocs/engine/Shopware/Components/DependencyInjection/Container.php(143): Shopware\Components\DependencyInjection\Container->doLoad('shopware_plugin...', 1)
#7 /pfad/zum/shop/httpdocs/var/cache/production_201807181357/proxies/ShopwareProduction14ca002122cedc8419e1085aec506909b8c098b7ProjectContainer.php(2447): Shopware\Components\DependencyInjection\Container->get('shopware_plugin...')
#8 /pfad/zum/shop/httpdocs/vendor/symfony/dependency-injection/Container.php(297): ShopwareProduction14ca002122cedc8419e1085aec506909b8c098b7ProjectContainer->getShopwarePlugininstaller_StoreClientService()
#9 /pfad/zum/shop/httpdocs/engine/Shopware/Components/DependencyInjection/Container.php(211): Symfony\Component\DependencyInjection\Container->get('shopware_plugin...', 1)
#10 /pfad/zum/shop/httpdocs/engine/Shopware/Components/DependencyInjection/Container.php(143): Shopware\Components\DependencyInjection\Container->doLoad('shopware_plugin...', 1)
#11 /pfad/zum/shop/httpdocs/var/cache/production_201807181357/proxies/ShopwareProduction14ca002122cedc8419e1085aec506909b8c098b7ProjectContainer.php(2455): Shopware\Components\DependencyInjection\Container->get('shopware_plugin...')
#12 /pfad/zum/shop/httpdocs/vendor/symfony/dependency-injection/Container.php(297): ShopwareProduction14ca002122cedc8419e1085aec506909b8c098b7ProjectContainer->getShopwarePlugininstaller_SubscriptionServiceService()
#13 /pfad/zum/shop/httpdocs/engine/Shopware/Components/DependencyInjection/Container.php(211): Symfony\Component\DependencyInjection\Container->get('shopware_plugin...', 1)
#14 /pfad/zum/shop/httpdocs/engine/Shopware/Components/DependencyInjection/Container.php(143): Shopware\Components\DependencyInjection\Container->doLoad('shopware_plugin...', 1)
#15 /pfad/zum/shop/httpdocs/engine/Shopware/Plugins/Default/Backend/PluginManager/Controllers/Backend/PluginManager.php(212): Shopware\Components\DependencyInjection\Container->get('shopware_plugin...')
#16 /pfad/zum/shop/httpdocs/engine/Library/Enlight/Controller/Action.php(193): Shopware_Controllers_Backend_PluginManager->getPluginInformationAction()
#17 /pfad/zum/shop/httpdocs/engine/Library/Enlight/Controller/Dispatcher/Default.php(549): Enlight_Controller_Action->dispatch('getPluginInform...')
#18 /pfad/zum/shop/httpdocs/engine/Library/Enlight/Controller/Front.php(222): Enlight_Controller_Dispatcher_Default->dispatch(Object(Enlight_Controller_Request_RequestHttp), Object(Enlight_Controller_Response_ResponseHttp))
#19 /pfad/zum/shop/httpdocs/engine/Shopware/Kernel.php(215): Enlight_Controller_Front->dispatch()
#20 /pfad/zum/shop/httpdocs/vendor/symfony/http-kernel/HttpCache/HttpCache.php(486): Shopware\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /pfad/zum/shop/httpdocs/engine/Shopware/Components/HttpCache/AppCache.php(268): Symfony\Component\HttpKernel\HttpCache\HttpCache->forward(Object(Symfony\Component\HttpFoundation\Request), true, NULL)
#22 /pfad/zum/shop/httpdocs/vendor/symfony/http-kernel/HttpCache/HttpCache.php(253): Shopware\Components\HttpCache\AppCache->forward(Object(Symfony\Component\HttpFoundation\Request), true)
#23 /pfad/zum/shop/httpdocs/engine/Shopware/Components/HttpCache/AppCache.php(105): Symfony\Component\HttpKernel\HttpCache\HttpCache->pass(Object(Symfony\Component\HttpFoundation\Request), true)
#24 /pfad/zum/shop/httpdocs/shopware.php(122): Shopware\Components\HttpCache\AppCache->handle(Object(Symfony\Component\HttpFoundation\Request))
#25 {main}
thrown in /pfad/zum/shop/httpdocs/custom/plugins/SwagMediaS3/vendor/guzzlehttp/guzzle/src/Client.php on line 128

build.sh fails, method call fails

michael@michael-linux:~/webdev/custom/plugins/SwagMediaS3$ ./build.sh 
Loading composer repositories with package information
Installing dependencies from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for aws/aws-sdk-php 3.32.6 -> satisfiable by aws/aws-sdk-php[3.32.6].
    - aws/aws-sdk-php 3.32.6 requires guzzlehttp/guzzle ^5.3.1|^6.2.1 -> no matching package found.
  Problem 2
    - Installation request for league/flysystem-aws-s3-v3 1.0.13 -> satisfiable by league/flysystem-aws-s3-v3[1.0.13].
    - league/flysystem-aws-s3-v3 1.0.13 requires league/flysystem ~1.0 -> no matching package found.


  adding: SwagMediaS3/ (stored 0%)
  adding: SwagMediaS3/SwagMediaS3.php (deflated 60%)
  adding: SwagMediaS3/README.rst (deflated 50%)
  adding: SwagMediaS3/composer.json (deflated 47%)
  adding: SwagMediaS3/.gitignore (stored 0%)
  adding: SwagMediaS3/LICENSE (deflated 42%)
  adding: SwagMediaS3/build.sh (deflated 48%)
  adding: SwagMediaS3/plugin.xml (deflated 41%)
  adding: SwagMediaS3/composer.lock (deflated 82%)

so i tried again with
composer update --lock
and
composer install
afterwards

then it seems to finish pulling in the dependencies, but the plugin seems to be broken. here is the xdebug-errormessage, I get when I try to open the plugin manager. loading the pluginmanager fails then:

Fatal error: Uncaught TypeError: Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, string given, called in /home/michael/webdev/custom/plugins/SwagMediaS3/vendor/guzzlehttp/guzzle/src/Client.php on line 89 and defined in /home/michael/webdev/custom/plugins/SwagMediaS3/vendor/guzzlehttp/guzzle/src/Client.php on line 128

here the same problem was reported already: https://forum.shopware.com/discussion/comment/218672/#Comment_218672 and guzzle/guzzle#1994

2 Dependencies are missing

        "league/flysystem": "~1.0",
        "guzzlehttp/guzzle": "~5.3.1"

Error:
PHP Fatal error: Uncaught Error: Class 'GuzzleHttp\ClientInterface' not found in /Users/philippbucher/Sites/flugzeugshop/vendor/aws/aws-sdk-php/src/functions.php:265

Both Packages are missing in my composer.lock and in the vendor folder. Comment says that the 2 packages are provides by shopware. But i can't find them.
I could provide a pull request, but i don't now what i have to change. Is ist because of the "replace" key in the composer.json?

Allowed memory size exhausted

Our media folder has a size of about 50 GB. When calling the migration service with

php -f bin/console sw:media:migrate --from=local --to=s3

the script aborts after about 10 seconds with:

Allowed memory size of 4294967296 bytes exhausted

What can we do to migrate our media folder to s3?

EDIT: as you can see, currently i've set the PHP memory_limit to 4 GB

Not a plugin?

Just wondering, why isn't this a plugin you can find in the Shopware Store?

(The MIT License would allow it to be done by anyone, but it wouldn't feel right)

Migration fails because of OptionResolver but config is set

Config file is set according to README

<?php return array (
  'db' => 
  array (
    'host' => 'localhost',
    'port' => '3306',
    'username' => 'staging',
    'password' => 'secure',
    'dbname' => 'somedb',
  ),
  'cdn' => [
    'backend' => 's3',
    'adapters' => [
      's3' => [
        'type' => 's3',
        'mediaUrl' => 'https://cdn.someurl.com/',
        'key' => 'some KEY',
        'secret' => 'some SECRET',
        'region' => 'eu-central-1',
        'bucket' => 'bucket-name',
        'prefix' => ''
      ]
    ]
  ],
);

but migration returns

bin/console sw:media:migrate --from=local --to=s3

In OptionsResolver.php line 645:

  The options "key", "prefix", "secret" do not exist. Defined options are: "bucket", "credentials", "endpoint",
  "mediaUrl", "region", "root", "type", "url", "version".


sw:media:migrate [--from [FROM]] [--to [TO]] [--skip-scan]

Fatal error

I have extracted the plugins to /engine/Shopware/Plugins/Local and installed + activated the SwagMediaS3 plugin. In the plugin manager I get this error message:
Fatal error: Unsupported operand types in /data/shopware/engine/Shopware/Plugins/Local/Frontend/SwagMediaS3/vendor/guzzlehttp/guzzle/src/Client.php on line 225 503 Service Unavailable

Right now I haven't configured any S3 credentials yet, if this is that is the reason you should print an appropiate error message.

Vendor Folder is missing

Last time I executed the ./build.sh it also downloaded the vendor folder. This is missing since my last download.

How to download the plugin?

The ReadMe says:
Download the plugin from the release page and enable it in shopware.
But I can not find the mentioned release page.
Would you mind sharing a link?
Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.