Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

s3client

39 sites Security covered
View on drupal.org

Overview

This is a developer-focused module that provides a simple factory for an S3 client.
It is not intended for integration with Drupal's file system and does not register a stream wrapper.
It is only intended for developers who wish to inject an S3 client factory into their services and then interact directly with the client to e.g. put, list and get objects from S3.

Installation

Install with composer, which will take care of fetching the AWS SDK.
composer require drupal/s3client

Configuration

There is no configuration or UI for the module, however you can declare credentials in your settings.php to support a default client.

$settings['s3client.default_key'] = 'YOUR KEY HERE';
$settings['s3client.default_secret'] = 'YOUR SECRET HERE';
$settings['s3client.default_region'] = 'us-east-1'; // Or your preferred region.

Typically this would be done with environment variables or a secrets management library.

$settings['s3client.default_key'] = getenv('S3_CLIENT_KEY');
$settings['s3client.default_secret'] = getenv('S3_CLIENT_SECRET');
$settings['s3client.default_region'] = getenv('S3_CLIENT_REGION'); // Or your preferred region.
// Advanced features for those using a service OTHER than AWS
$settings['s3client.default_endpoint'] = 'https://s3.example.com'; // Not required with AWS endpoint.
$settings['s3client.default_bucket_endpoint'] = TRUE; // If your endpoint is directly pointing to your bucket, you want to set this to TRUE. It has no effect if s3client.default_endpoint is undefined, default: FALSE.
$settings['s3client.default_version'] = 'latest'; // Default: 2006-03-01.

Usage

Default client

To inject the default client into your classes, use the s3client.s3client service.

In your services..yml

services:
  mymodule.something_s3:
    class: 'Drupal\mymodule\SomethingS3'
    arguments:
      - '@s3client.s3client'

Then you can interact directly with the client per the AWS documentation.

Injecting the factory

To inject the client factory into your classes, use the s3client.factory service.

In your services..yml

services:
  mymodule.something_s3:
    class: 'Drupal\mymodule\SomethingS3'
    arguments:
      - '@s3client.factory'

Then you can get a client as required using the createClient method like so

$client = $factory->createClient($key, $secret, $region);

// If you use a service other than AWS S3 you can also pass endpoint, bucket endpoint and version, see settings docs above.
$client = $factory->createClient($key, $secret, $region, $endpoint, $bucketEndpoint, $version);

Known problems

Please use the issue queue to report issues.

Activity

Total releases
1
First release
Sep 2025
Latest release
7 months ago
Release cadence
Stability
100% stable

Releases

Version Type Release date
1.2.0 Stable Sep 11, 2025