Skip to content

Commit a14e7c7

Browse files
committed
feat: add S3 usage guide and update setup documentation for remote sources
1 parent 2d80e7a commit a14e7c7

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

docs/.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export default defineConfig({
5454
{ text: 'Signed URLs', link: '/signed-urls' },
5555
{ text: 'Image Caching', link: '/image-caching' },
5656
{ text: 'Rate Limiting', link: '/rate-limiting' },
57+
{ text: 'S3 Usage', link: '/s3-usage' },
5758
{ text: 'CDN Usage', link: '/cdn-usage' },
5859
{ text: 'Error Handling', link: '/error-handling' },
5960
]

docs/pages/s3-usage.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Usage with S3
2+
3+
This guide explains how to configure this package to work with S3-compatible storage services like AWS S3 or Cloudflare R2.
4+
This enables you to transform and serve images stored remotely without the need to store images on your local server.
5+
6+
1. Set up your S3 disk in your [filesystems configuration](https://laravel.com/docs/filesystem#amazon-s3-compatible-filesystems), install the [S3 package](https://laravel.com/docs/filesystem#s3-driver-configuration) and ensure you have the necessary credentials and settings for your S3 bucket. Public bucket access is not required.
7+
8+
2. Configure the package via `image-transform-url.php` to include your S3 disk in the `source_directories` as described in [the setup guide](/setup#configuring-remote-sources).
9+
10+
3. If you are using the [Image Caching](/image-caching) feature and want to store transformed images back to your S3 bucket instead of your local filesystem, you may also set the `cache.disk` option in the `image-transform-url.php` configuration file to your S3 disk.
11+
12+
```php
13+
'cache' => [
14+
//...
15+
'disk' => env('IMAGE_TRANSFORM_CACHE_DISK', 's3'),
16+
//...
17+
],
18+
```
19+
20+
::: warning
21+
Having the `cache.disk` set to your S3 disk may result in higher latency and costs due to the nature of remote storage. If you are concerned about performance, consider using a local disk for caching and only use S3 for the source directories.
22+
:::
23+
24+
4. You can now use the [image transformation URLs](/getting-started) as usual, and the package will handle fetching images from your S3 bucket.

docs/pages/setup.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ An example source directory configuration might look like this:
2222
| Important: The public storage directory should be addressed directly via
2323
| storage('app/public') instead of the public_path('storage') link.
2424
|
25+
| You can also use any Laravel Filesystem disk (e.g. S3) by providing an
26+
| array configuration with 'disk' and an optional 'prefix'.
27+
|
2528
*/
2629
'source_directories' => [
2730
'images' => public_path('images'),
@@ -40,3 +43,18 @@ An example source directory configuration might look like this:
4043
'default_source_directory' => env('IMAGE_TRANSFORM_DEFAULT_SOURCE_DIRECTORY', 'images'),
4144
// ...
4245
```
46+
47+
## Configuring Remote Sources
48+
If you want to use a remote source (like AWS S3 or Cloudflare R2) as a source directory, you can configure any [Laravel Filesystem disk](https://laravel.com/docs/filesystem#configuration) in your `config/filesystems.php` file and then reference it in the `source_directories` configuration.
49+
50+
```php
51+
'source_directories' => [
52+
// Other source directories...
53+
'remote' => [
54+
'disk' => 's3', // Any valid Laravel Filesystem disk
55+
'prefix' => 'images', // Optional, if you want to specify a subdirectory
56+
],
57+
],
58+
```
59+
60+
Read the [full guide on how to use this package with S3](/s3-usage.md).

0 commit comments

Comments
 (0)