Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

S3 Client

42 sites Security covered
View on drupal.org

This module provides a factory to create an S3 client, intended for developers to integrate directly with S3 services for tasks like uploading, listing, and retrieving objects. It is not designed to integrate with Drupal's file system or provide a stream wrapper.

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
10 months ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Slowing

Releases

Version Type Release date
1.2.0 Stable Sep 11, 2025