Skip to Content
Apricot Framework

S3

AWS S3 and S3-compatible servers, with the settings, credentials, and how failures are classified.

ApricotFramework.ObjectStore.S3 backs a store with AWS S3 or any server that speaks its protocol — MinIO, Ceph, Cloudflare R2, RustFS and others.

builder.Services.AddS3ObjectStoreProvider();

A store reaches it with "Provider": "s3".

Settings

SettingDefaultMeans
Bucketrequiredthe bucket
Prefixnoneevery object of the store lives under it; avatars and avatars/ mean the same folder
Regionfrom the SDKthe AWS region, such as eu-west-1
ServiceUrlAWSa custom endpoint, for an S3-compatible server
PublicServiceUrlServiceUrlthe endpoint presigned URLs are signed for; see presigned URLs
ForcePathStyletrue with a ServiceUrlhost/bucket/key rather than bucket.host/key
AccessKeyId, SecretAccessKeydefault credential chainmust be set together
SessionTokennonefor temporary credentials
Timeout00:02:00per request
PresignedExpiry00:15:00how long a presigned URL works when the caller does not say
MaxPresignedExpiry01:00:00the longest one may work, up to 7.00:00:00, which is the limit of a signature
MultipartPartSize8388608bytes per part of a large upload, from 5 MiB to 512 MiB: a part is held in memory while it is sent
ChecksumModesee belowWhenSupported or WhenRequired

Durations are written hh:mm:ss. A bare number is refused rather than read as days, which is what TimeSpan would make of 30.

A half-set key pair is an error and not a quiet fallback to the default chain, because falling back would hide the mistake. Everything is checked when the host starts, so a missing bucket stops the host and not the first upload.

S3-compatible servers

"local": {
  "Provider": "s3",
  "Settings": { "Bucket": "dev", "ServiceUrl": "http://localhost:9000" }
}

Setting ServiceUrl changes two defaults to what such servers need. Path-style addressing is turned on, because virtual-hosted addressing needs wildcard DNS. And ChecksumMode becomes WhenRequired: version 4 of the AWS SDK sends a CRC checksum with every upload, and many compatible servers reject the trailing-checksum encoding that carries it. Real AWS wants checksums, so it defaults to WhenSupported. Both can be set explicitly.

Requests are signed for us-east-1 unless Region says otherwise, which compatible servers ignore but signing still needs.

With neither Region nor ServiceUrl, the SDK looks for a region in the environment, a profile and the instance metadata service. If it finds none, the store fails with a configuration error naming the setting, and nothing is sent. On a machine with no metadata service the search can take several seconds before it gives up.

How failures are classified

Every SDK failure passes through one translator, and the message carries the vendor's error code and HTTP status and nothing else — the SDK's own message routinely names the bucket, the endpoint and the key. The full exception stays as the inner exception.

SDK errorObjectStoreErrorCode
NoSuchKey, NoSuchUpload, 404NotFound
NoSuchBucketConfiguration
412PreconditionFailed, or AlreadyExists for a create-only write
AccessDenied, SignatureDoesNotMatch, InvalidAccessKeyId, 401, 403AccessDenied
SlowDown, 429, 503Throttled
RequestTimeout, 408, 504, a timeout in the HTTP stackTimeout
other 5xx, an unreachable serverUnavailable
InvalidArgument, EntityTooLarge, 400, 416InvalidRequest
anything elseUnknown

A failure reading your own stream — a dropped upload on the way in — surfaces as it was, not as an unavailable store, because retrying cannot fix it.

Large uploads

Ten thousand parts is the most S3 takes, so the part size is chosen for the object: when the length is known and ten thousand parts of the configured size would not hold it, the parts are made bigger, in whole mebibytes. For a stream whose length is not known, the size doubles every thousand parts. The ceiling of 512 MiB per part covers objects up to about 4.9 TiB, a little under the 5 TiB S3 allows; a larger one is refused before anything is sent.

Large copies

A copy is one request up to 5 GB. Beyond that the provider reads the source in ranges on the server and assembles the copy as a multipart upload, with nothing passing through your process. Content type, Content-Disposition, Cache-Control and metadata come across either way.

Two stores copy on the server only when they reach the same endpoint as the same identity: the same URL, region, access key and secret. Otherwise the content is streamed through your process, and the result is the same.

On this page