Skip to content

Commit 760eb16

Browse files
author
Arjan Lankhaar
committed
feat: added docs for custom HTTP client injection for S3 client creation
1 parent a27f8cc commit 760eb16

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

guides/hosting/infrastructure/filesystem.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,82 @@ shopware:
221221

222222
If your S3 provider does not use buckets as subdomain like Minio in default configuration, you need to set `use_path_style_endpoint` to `true` inside `config`.
223223

224+
#### Custom HTTP client for S3
225+
226+
By default, the underlying AsyncAws S3 client creates its own HTTP client internally, which includes a `RetryableHttpClient` with an AWS-specific retry strategy. This handles transient errors like throttling (HTTP 429), server errors (HTTP 5xx), and other AWS-specific error codes automatically.
227+
228+
If you need to customize the HTTP behavior for S3 operations (e.g., timeouts, HTTP protocol version, or proxy settings), you can register a service with the ID `shopware.filesystem.s3.client`. When this service exists, Shopware injects it into both the filesystem adapter and presigned URL generation.
229+
230+
::: info
231+
When you provide a custom HTTP client, AsyncAws will **not** wrap it in its own `RetryableHttpClient`. If you need retry behavior, you must configure it yourself as shown below.
232+
:::
233+
234+
**Simple configuration** (custom timeouts, no retry handling):
235+
236+
```yaml
237+
# config/packages/framework.yaml
238+
framework:
239+
http_client:
240+
scoped_clients:
241+
s3.http_client:
242+
base_uri: '{your-s3-endpoint}'
243+
timeout: 30.0
244+
http_version: '1.1'
245+
```
246+
247+
```xml
248+
<!-- config/services.xml -->
249+
<service id="shopware.filesystem.s3.client" alias="s3.http_client"/>
250+
```
251+
252+
**Recommended configuration** (custom settings with AWS retry support):
253+
254+
```yaml
255+
# config/packages/framework.yaml
256+
framework:
257+
http_client:
258+
scoped_clients:
259+
s3.http_client:
260+
base_uri: '{your-s3-endpoint}'
261+
timeout: 30.0
262+
http_version: '1.1'
263+
```
264+
265+
```xml
266+
<!-- config/services.xml -->
267+
<service id="AsyncAws\Core\HttpClient\AwsRetryStrategy"/>
268+
269+
<service id="shopware.filesystem.s3.client" class="Symfony\Component\HttpClient\RetryableHttpClient">
270+
<argument type="service" id="s3.http_client"/>
271+
<argument type="service" id="AsyncAws\Core\HttpClient\AwsRetryStrategy"/>
272+
<argument>3</argument><!-- max retries -->
273+
</service>
274+
```
275+
276+
This wraps your scoped client in a `RetryableHttpClient` with the same `AwsRetryStrategy` that AsyncAws uses by default, preserving retry behavior for AWS-specific transient errors while allowing you to control timeouts, HTTP version, and other transport-level settings.
277+
278+
**Without scoped clients** (standalone service definition with retry support):
279+
280+
```yaml
281+
# config/services.yaml
282+
services:
283+
s3.http_client:
284+
class: Symfony\Contracts\HttpClient\HttpClientInterface
285+
factory: ['Symfony\Component\HttpClient\HttpClient', 'create']
286+
arguments:
287+
-
288+
timeout: 30
289+
290+
shopware.filesystem.s3.client:
291+
class: Symfony\Component\HttpClient\RetryableHttpClient
292+
arguments:
293+
- '@s3.http_client'
294+
- ~
295+
- 3
296+
```
297+
298+
This creates a plain HTTP client via `HttpClient::create()` with custom options and wraps it in a `RetryableHttpClient` with the default retry strategy.
299+
224300
### Google Cloud Platform
225301

226302
In order to use the Google Cloud Platform adapter you need to install the `league/flysystem-google-cloud-storage` package.

0 commit comments

Comments
 (0)