Skip to main content

S3 File Storage

note

This guide assumes familiarity with the Spring Framework.
If you are new to Spring, we recommend starting with their official guides to get up to speed.

S3 (Simple Storage Service) is an object storage service offered by many cloud providers. Unlike traditional file systems, which use a hierarchical structure, S3 stores data as objects within "buckets." This architecture provides significant benefits for a file storage system like Singularity, making it a highly suitable choice for production environments.

Why S3 is Useful

In the context of Singularity, using S3 for file storage is a powerful alternative to local storage. It offers:

  • Scalability: S3 provides virtually unlimited storage capacity. This means your application can grow and handle an enormous number of files without requiring you to manage or provision the underlying disk space.
  • Durability and Availability: S3 is designed for 99.999999999% durability by automatically replicating data across multiple servers in different locations. This ensures your files are highly resistant to loss and are always accessible.
  • Security: S3 offers robust security features, including encryption at rest and in transit, and fine-grained access controls. This is critical for protecting user-uploaded data.
  • Cost-Effectiveness: S3 operates on a pay-as-you-go model, so you only pay for the storage you use. It also offers different storage classes, allowing you to optimize costs by moving less-frequently accessed files to cheaper tiers.

Configuration

PropertyTypeDescriptionDefault Value
singularity.file.storage.typeStringThe file storage type to use. The framework supports s3 or local.s3
singularity.file.storage.s3.domainStringThe S3 endpoint URL.
singularity.file.storage.s3.schemeEnum (HTTP, HTTPS)The scheme for the S3 endpoint URL.HTTP
singularity.file.storage.s3.accessKeyStringYour AWS access key for programmatic access.
singularity.file.storage.s3.secretKeyStringYour AWS secret key for programmatic access.
singularity.file.storage.s3.bucketStringThe name of the S3 bucket where files will be stored.app
singularity.file.storage.s3.pathStringThe path inside the bucket where the files will be stored.
singularity.file.storage.s3.regionEnum (Region)The AWS region of your bucket (e.g., EU_CENTRAL_1).
singularity.file.storage.s3.signatureDurationLongThe duration in minutes for which pre-signed URLs are valid.5
singularity.file.storage.s3.pathStyleAccessEnabledBooleanSet to true if you are using an S3-compatible service that requires path-style access.false

Example application.yml

singularity:
file:
storage:
type: s3
s3:
domain: "s3.your-domain.com"
scheme: HTTPS
bucket: "my-singularity-app-files"
region: EU_CENTRAL_1
access-key: "YOUR_ACCESS_KEY"
secret-key: "YOUR_SECRET_KEY"
signature-duration: 5