Storage Provider Reference
Slink supports multiple storage providers for storing images. By default, the application uses the local file system to store images. However, you can configure the application to use a different storage provider by setting the STORAGE_PROVIDER
environment variable.
Local Storage Provider
Section titled “Local Storage Provider”The local storage provider stores images on the local filesystem. This is the default provider and requires no additional configuration beyond specifying the storage directory.
Configuration:
STORAGE_PROVIDER=local
- Images are stored in
/app/slink/images
- Cache files are stored in
/app/slink/cache
SMB (Samba) Storage Provider
Section titled “SMB (Samba) Storage Provider”The SMB storage provider allows you to store images on a network share using the SMB/CIFS protocol. This is useful for centralized storage in enterprise environments.
Required Configuration:
STORAGE_PROVIDER=smb
SMB_HOST
- The hostname or IP address of your SMB serverSMB_SHARE
- The name of the SMB share to useSMB_USERNAME
- Username for authenticationSMB_PASSWORD
- Password for authentication
Optional Configuration:
SMB_WORKGROUP
- The SMB workgroup (defaults to ‘workgroup’)
Example Docker Compose configuration:
environment: STORAGE_PROVIDER: smb SMB_HOST: 192.168.1.100 SMB_SHARE: slink-storage SMB_USERNAME: slink-user SMB_PASSWORD: your-secure-password SMB_WORKGROUP: workgroup
Amazon S3 Storage Provider
Section titled “Amazon S3 Storage Provider”The Amazon S3 storage provider stores images in an AWS S3 bucket. This is ideal for cloud deployments and provides scalable object storage.
Required Configuration:
STORAGE_PROVIDER=s3
AMAZON_S3_REGION
- AWS region where your bucket is located (e.g.,us-east-1
)AMAZON_S3_BUCKET
- Name of your S3 bucketAMAZON_S3_ACCESS_KEY_ID
- AWS access key IDAMAZON_S3_SECRET_ACCESS_KEY
- AWS secret access key
Example Docker Compose configuration:
environment: STORAGE_PROVIDER: s3 AMAZON_S3_REGION: us-east-1 AMAZON_S3_BUCKET: my-slink-bucket AMAZON_S3_ACCESS_KEY_ID: EXAMPLEKEYID AMAZON_S3_SECRET_ACCESS_KEY: exampleSecretKey
Storage Provider Architecture
Section titled “Storage Provider Architecture”Slink uses a proxy pattern to abstract storage operations. The StorageProxy
class automatically routes operations to the configured storage provider based on the STORAGE_PROVIDER
environment variable.
Supported Operations:
- Upload files with automatic directory creation
- Read and write file content
- Delete files
- Check file existence
- Image transformation and caching
Directory Structure: All storage providers maintain a consistent directory structure:
slink/images/
- Original uploaded imagesslink/cache/
- Transformed/cached images