Frameworks & Applications

See what we're up to: Runway is here! 🚀

Frameworks & Applications #

The following examples illustrate how to work with the AWS-SDK and our object storage.

By following the examples, you’ll discover that configuration options are the same across different languages and frameworks.

We hope, this will help you get started even if this page does not include your language or framework of choice.

If you happen to run into challenges, please get in touch.

Ecommerce #

Magento #

Magento has a complete guide online: https://devdocs.magento.com/guides/v2.4/config-guide/remote-storage/config-remote-storage-aws-s3.html

To configure magento with our object storage, use the following options:

$ bin/magento setup:config:set \
    --remote-storage-driver="aws-s3" \
    --remote-storage-endpoint="https://s3.storage.planetary-networks.de" \
    --remote-storage-region="us-east-1" \
    --remote-storage-bucket="bucket-name.example.org" \
    --remote-storage-key="your-key-id" \
    --remote-storage-secret="your-secret" \
    --no-interaction

Shopware #

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
shopware:
  filesystem:
    {ADAPTER_NAME}:
      type: "amazon-s3"
      visibility: "private"
      config:
        bucket: "bucket-name.example.org"
        region: "us-east-1"
        endpoint: "https://s3.storage.planetary-networks.de"
        root: "/"

More details: https://developer.shopware.com/docs/guides/hosting/infrastructure/filesystem#amazon-s3

CMS and PHP #

Typo3 #

In order to add object storage support to Typo3, the following extension can be used: https://extensions.typo3.org/extension/aus_driver_amazon_s3

After installation, set the appropriate values in the configuration screen:

  • endpoint/custom host: https://s3.storage.planetary-networks.de/
  • region: anything
  • bucket: your bucket
  • credentials (key/secret): your-key-id / your-secret

Wordpress #

Various plugins are available for Wordpress:

Follow the instructions, and add the usual to make your wordpress compatible.

Pimcore #

Pimcore uses a library called flysystem under the hood, this means, all storage adapters are available.

Install the adapter:

$ composer require league/flysystem-aws-s3-v3:^2.0

And configure the service and override the storage:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# config/packages/prod/flysystem.yaml
services:
  assets_s3:
    class: 'Aws\S3\S3Client'
    arguments:
      - endpoint: 'https://s3.storage.planetary-networks.de'
        region: 'us-east-1'
        credentials:
            key: 'your-key-id'
            secret: 'your-secret'

# config/packages/prod/flysystem.yaml
flysystem:
  storages:
    pimcore.asset.storage:
      adapter: 'aws'
      visibility: public
      options:
        client: 'assets_s3'
        bucket: 'bucket-name.example.org'
        prefix: assets

PHP (e.g. Symfony, Laraval, …) #

Install the dependency using composer:

$ composer require aws/aws-sdk-php

Create an $client object and register the stream wrapper:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
<?php
$client = new Aws\S3\S3Client([
    'credentials' => [
      'access_key_id' => 'your-key-id',
      'secret_access_key' => 'your-secret',
    ],
    'endpoint' => 'https://s3.storage.planetary-networks.de',
    'region' => 'us-east-1',
    'bucket' => 'bucket-name.example.org', 
]);

// Register the stream wrapper from an S3Client object
$client->registerStreamWrapper();

Going forward, you can create and access files, like so:

1
2
3
4
5
<?php
// creates: https://s3.storage.planetary-networks.de/bucket-name.example.org/name-of-the-file'
file_put_contents('s3://name-of-the-file', 'Hello World');

var_dump(file_get_contents('s3://name-of-the-file));

Ruby #

ActiveStorage #

Add the client to your Gemfile:

1
gem "aws-sdk-s3", require: false

And configure ActiveStorage:

1
2
3
4
5
6
7
amazon:
  service: S3
  access_key_id: 'your-key-id'
  secret_access_key: 'your-secret'
  endpoint: 'https://s3.storage.planetary-networks.de'
  region: 'us-east-1'
  bucket: 'bucket-name.example.org'

Further information: https://edgeguides.rubyonrails.org/active_storage_overview.html#s3-service-amazon-s3-and-s3-compatible-apis

CarrierWave (Rails, Sinatra) #

Follow the instructions on Github to add CarrierWave to your project.

For the actual configuration, use the following as an example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
CarrierWave.configure do |config|
  minio_config = Rails.application.config_for :minio
  config.fog_provider    = 'fog/aws'
  config.fog_credentials = {
    provider:                      'AWS',
    aws_access_key_id:             'your-key-id',
    aws_secret_access_key:         'your-secret',
    host:                          's3.planetary-networks.de',
    endpoint:                      'https://s3.storage.planetary-networks.de',
    path_style:                    true,
    enable_signature_v4_streaming: false
  }

  config.fog_directory = 'some_directory'
  config.asset_host    = ActionController::Base.asset_host
end

JavaScript/nodejs (e.g. expressjs) #

Install the client into your project:

$ npm install @aws-sdk/client-s3 --save

Create an s3Client object for use:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import { S3Client} from "@aws-sdk/client-s3";

const s3Client = new S3Client({
  access_key_id: 'your-key-id',
  secret_access_key: 'your-secret',
  endpoint: 'https://s3.storage.planetary-networks.de',
  region: 'us-east-1',
  bucket: 'bucket-name.example.org'
});

// ...

Java (e.g. Spring Boot with Gradle) #

Add the dependency to Gradle:

1
compile group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.767'

Add settings to your application.properties:

1
2
3
4
5
s3.endpointUrl=https://s3.storage.planetary-networks.de
s3.accessKeyId=your-key-id
s3.secretKey=your-secret
s3.bucketName=bucket-name.example.org
s3.region=us-east-1

Implement a client:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
@Service
public class AmazonClient
{
  private AmazonS3 s3client;

  @Value("${s3.endpointUrl}")
  private String endpointUrl;

  @Value("${s3.bucketName}")
  private String bucketName;

  @Value("${s3.accessKeyId}")
  private String accessKeyId;

  @Value("${s3.secretKey}")
  private String secretKey;

  @Value("${s3.region}")
  private String region;

  @PostConstruct
  private void initializeAmazon()
  {
    AWSCredentials credentials = new BasicAWSCredentials(
      this.accessKeyId,
      this.secretKey
    );

    this.s3client = AmazonS3ClientBuilder
      .standard()
      .withRegion(this.region)
      .withEndpoint(this.endpointUrl)
      .withCredentials(new AWSStaticCredentialsProvider(credentials))
      .build();
  }

  // ...
}

Use it in a controller:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
@RestController
@RequestMapping("/some/url/")
public class SuperDuperController
{
  private AmazonClient amazonClient;

  @Autowired
  SuperDuperController(AmazonClient amazonClient)
  {
    this.amazonClient = amazonClient;
  }

  // ...
}