Complete the Quick start first. Keep the silo database, the attachments bucket, the app-s3 user and the trusted gateway CA certificate for these tutorials.
Upload parts with cleanup, apply retention and legal hold, deliver bucket notifications or SQL outbox events, and issue service accounts or STS credentials
Use the root account only for administration. Use restricted IAM policies for S3 applications, and manage PostgreSQL login roles separately from S3 access keys.
1 - Objects from SQL
Write and read objects inside a PostgreSQL transaction with silo_api.
Note
The SQL transaction API (silo_api) and PostgreSQL native authorization (silo_bucket) are Preview features in the MVP scope.
This tutorial writes an invoice row and its attachment in one PostgreSQL transaction, verifies both from SQL and S3, rolls back a second transaction, and reads paginated lists and object segments. Complete the Quick start first so the silo database and plaintext attachments bucket exist.
Create an application SQL role
Connect to silo as a database administrator and create an unprivileged login role (app_sql) and application schema (app_demo):
The application role needs no superuser rights, no membership in silo_owner, and no direct access to the private silo schema.
Next, connect to silo as the installation owner (silo_owner) and grant EXECUTE on the required silo_api functions plus SELECT and INSERT on the ACL relation for attachments:
GRANTUSAGEONSCHEMAsilo_api,silo_bucketTOapp_sql;GRANTEXECUTEONFUNCTIONsilo_api.put_object(text,text,bytea,text,jsonb,boolean,text),silo_api.get_object(text,text,uuid),silo_api.stat_object(text,text,uuid),silo_api.read_object(text,text,bigint,bigint,uuid,bigint),silo_api.list_objects(text,text,text,integer)TOapp_sql;SELECTformat('GRANT SELECT, INSERT ON TABLE %I.%I TO %I',n.nspname,c.relname,'app_sql')FROMsilo.bucket_aclASaJOINsilo.bucketsASbONb.id=a.bucket_idJOINpg_catalog.pg_classAScONc.oid=a.relation_oidJOINpg_catalog.pg_namespaceASnONn.oid=c.relnamespaceWHEREb.name='attachments'ANDn.nspname='silo_bucket'\gexec
In psql, \gexec executes the generated GRANT statement. Because a bucket’s ACL relation name in silo_bucket is decoupled from the bucket name, silo_owner looks it up through silo.bucket_acl. See Authorization for the complete permission mapping.
Reconnect as app_sql and create the business table:
get_object returns bytea. Use convert_from only when the payload is known UTF-8 text.
Roll back a business row and object together
Start a second transaction, write both the object and the invoice row, and roll back:
BEGINISOLATIONLEVELREADCOMMITTED;WITHwrittenAS(SELECT*FROMsilo_api.put_object('attachments','invoices/1002.txt',convert_to('this invoice will be rolled back','UTF8'),'text/plain'))INSERTINTOapp_demo.invoices(invoice_id,object_key,object_id,object_version,amount)SELECT1002,'invoices/1002.txt',object_id,version_id,299.00FROMwritten;ROLLBACK;SELECTcount(*)FROMapp_demo.invoicesWHEREinvoice_id=1002;SELECTcount(*)FROMsilo_api.list_objects('attachments','invoices/1002.txt');
Both counts return 0. Neither the relational row nor the S3 object is published.
If your application needs a permanent reference to an immutable object body, enable bucket versioning and pass the saved version_id when calling get_object, stat_object or read_object. Overwriting an unversioned object replaces its body.
Paginate listings and read segments
List the first page of objects under the invoices/ prefix:
To fetch the next page, pass the final key of the current page as the third argument (start_after). Each call returns at most 1,000 live objects in C byte order and omits delete markers.
To read a large object in bounded chunks without materializing the full body in one call, open a read-only Repeatable Read snapshot and call read_object:
BEGINISOLATIONLEVELREPEATABLEREADREADONLY;SELECTobject_id,version_id,offset_bytes,octet_length(data)FROMsilo_api.read_object('attachments','invoices/1001.txt',0,8388608);-- Advance offset_bytes on subsequent calls within the same transaction.
COMMIT;
read_object returns at most 8 MiB (8388608 bytes) per call. Use REPEATABLE READ only for read-only transactions; SQL writes through silo_api require READ COMMITTED.
Direct SQL writes do not emit S3 bucket notifications. To publish events atomically with SQL object writes, insert into a transactional outbox table in the same transaction; see Multipart, Object Lock and STS and the SQL API reference.
2 - Use an S3 SDK
Connect AWS SDKs and mc-compatible clients to the gateway.
This tutorial connects the AWS CLI and the Python SDK (boto3) to a Silo PostgreSQL gateway, generates a presigned download URL, and configures bucket CORS for browser requests. Complete the Quick start first so the attachments bucket, app-s3 user and local hello.txt file exist.
Set the endpoint and working directory in your terminal:
Save the following script as ~/.local/share/silo-tutorial/sdk.py:
importosimportboto3frombotocore.configimportConfigsession=boto3.Session(profile_name="silo-app",region_name="us-east-1")s3=session.client("s3",endpoint_url=os.environ["SILO_ENDPOINT"],verify=os.environ["AWS_CA_BUNDLE"],config=Config(signature_version="s3v4",s3={"addressing_style":"path"}),)s3.put_object(Bucket="attachments",Key="sdk.txt",Body=b"hello from Python\n")response=s3.get_object(Bucket="attachments",Key="sdk.txt")try:print(response["Body"].read().decode("utf-8"))finally:response["Body"].close()
Run "$HOME/.local/share/silo-tutorial/venv/bin/python" "$HOME/.local/share/silo-tutorial/sdk.py". It prints hello from Python.
Keep default SDK checksums and TLS verification enabled. When uploading larger files with SDK multipart helpers, the completed object must fit within the store’s maximum object size (256 MiB by default, up to 1 GiB if configured at initialization).
Presigned URLs and bucket CORS
Generate a presigned GET URL valid for 15 minutes (900 seconds) using the s3 client from above:
A presigned URL carries the signing principal’s permissions and cannot grant access that the signer lacks. If signed by temporary STS credentials, the URL stops working when the session expires even if ExpiresIn is longer.
To allow browser uploads or downloads from another origin, configure a bucket CORS rule with an administrative profile (silo-admin):
A matching preflight request returns the allowed origin and methods in the response headers; a rejected preflight returns HTTP 403 (AccessForbidden). CORS headers do not bypass SigV4 signing or IAM authorization.
3 - Versioning
Enable versioning, read old versions and work with delete markers.
Note
Bucket versioning is a Supported MVP feature. Lifecycle rules, Object Lock and hard bucket quotas described in the second half of this page are Preview features.
This tutorial enables bucket versioning, writes multiple versions of an object, reads a historical version by VersionId, and configures lifecycle expiration and a hard bucket quota. Use the silo-admin profile and mcli_pg alias from the Quick start and Use an S3 SDK.
Retain and read historical versions
Create a dedicated version-demo bucket, enable versioning, write two versions of note.txt, and fetch the first version by its VersionId:
In a versioned bucket, calling delete-object without --version-id inserts a delete marker while preserving prior versions. Permanently deleting a specific version requires passing --version-id and holding s3:DeleteObjectVersion. Reading a historical version requires s3:GetObjectVersion.
Suspending versioning (Status=Suspended) switches new writes to null-version semantics without deleting existing historical versions.
Lifecycle rules and bucket quotas
Create a lifecycle-demo bucket and apply a lifecycle rule that expires current objects under tmp/ after 7 days and aborts incomplete multipart uploads after 1 day:
A background worker on a writable gateway scans for eligible objects under a database lease. Expiring historical versions requires a NoncurrentVersionExpiration rule. Remote storage-class transition rules (Transition / NoncurrentVersionTransition) are not supported and are rejected.
Hard bucket quotas count the committed object bodies and annotations of all live and historical versions (excluding delete markers). Unfinished multipart parts consume physical table space immediately, but count toward the logical bucket quota only when CompleteMultipartUpload publishes the object:
mcli_pg quota set pg-admin/attachments --size 1GiB
mcli_pg quota info pg-admin/attachments
Deleting versions releases logical quota immediately, whereas physical disk space is reclaimed and reused asynchronously by PostgreSQL VACUUM. See Storage layout for details.
4 - Encryption
SSE-C and static-key SSE-S3, and what they protect.
This tutorial configures static-key SSE-S3 (AES256) on a gateway and bucket, then runs a round-trip write and read with a client-supplied SSE-C customer key. Complete Install and Use an S3 SDK first.
Configure static-key SSE-S3
Generate a 32-byte key file once on the gateway host (refusing to overwrite an existing key file):
sudo sh -c 'set -eu; umask 027; test ! -e /etc/silo/kms.key; set -C; { printf "silo-key-1:"; openssl rand -base64 32; } > /etc/silo/kms.key; chown root:silo /etc/silo/kms.key; chmod 0640 /etc/silo/kms.key'
Back up the exact key ID (silo-key-1) and raw key bytes outside the database, and copy the identical /etc/silo/kms.key file to every gateway that connects to this PostgreSQL database.
Add MINIO_KMS_SECRET_KEY_FILE to /etc/default/silo (do not set MINIO_KMS_SECRET_KEY at the same time):
MINIO_KMS_SECRET_KEY_FILE="/etc/silo/kms.key"
Restart the gateway, enable default AES256 encryption on a new encrypted-demo bucket, and verify an encrypted upload and download:
If the static key is missing or wrong, encryption and decryption requests fail closed; the gateway never falls back to plaintext. Losing the external key makes encrypted objects in PostgreSQL unrecoverable. See Backup and restore.
External KMS integration and SSE-KMS (aws:kms) are not supported. The silo_api SQL interface cannot decrypt SSE-S3 or SSE-C bodies, and buckets with default encryption reject SQL put_object writes.
Use a client-held SSE-C key
With SSE-C, the client supplies the 32-byte key on every write and read over HTTPS. Save the following script as ~/.local/share/silo-tutorial/sse-c.py:
importbase64importhashlibimportosfrompathlibimportPathimportboto3frombotocore.configimportConfigkey_path=Path.home()/".local/share/silo-tutorial/sse-c.key"key_path.parent.mkdir(parents=True,exist_ok=True)ifkey_path.exists():key=key_path.read_bytes()else:key=os.urandom(32)descriptor=os.open(key_path,os.O_WRONLY|os.O_CREAT|os.O_EXCL,0o600)withos.fdopen(descriptor,"wb")asoutput:output.write(key)iflen(key)!=32:raiseValueError("SSE-C key must contain exactly 32 bytes")session=boto3.Session(profile_name="silo-admin",region_name="us-east-1")s3=session.client("s3",endpoint_url=os.environ["SILO_ENDPOINT"],verify=os.environ["AWS_CA_BUNDLE"],config=Config(signature_version="s3v4",s3={"addressing_style":"path"}),)customer_headers={"SSECustomerAlgorithm":"AES256","SSECustomerKey":base64.b64encode(key).decode("ascii"),"SSECustomerKeyMD5":base64.b64encode(hashlib.md5(key,usedforsecurity=False).digest()).decode("ascii"),}s3.create_bucket(Bucket="customer-key-demo")s3.put_object(Bucket="customer-key-demo",Key="private.txt",Body=b"protected by a client-held key\n",**customer_headers,)response=s3.get_object(Bucket="customer-key-demo",Key="private.txt",**customer_headers)try:assertresponse["Body"].read()==b"protected by a client-held key\n"print("SSE-C round trip succeeded")finally:response["Body"].close()
Run "$HOME/.local/share/silo-tutorial/venv/bin/python" "$HOME/.local/share/silo-tutorial/sse-c.py". It prints SSE-C round trip succeeded.
SSE-C requests require verified HTTPS; HTTP SSE-C requests are rejected. Back up the 32 bytes in sse-c.key independently — the gateway’s static SSE-S3 key cannot decrypt SSE-C objects.
5 - Annotations and ZIP
Attach annotations to objects and extract ZIP archives on upload.
Note
Object annotations (?annotation) and ZIP member extraction (x-minio-extract) are Preview features in the MVP scope. Annotations also depend on four silo-pkg policy actions (s3:*ObjectAnnotation*) that have not been published to the public silo-pkg repository yet, and the general Silo Console (2.6.0) does not include an annotation UI.
This tutorial uses SigV4-signed Python requests to write, read, list and delete object annotations, and to list and read members inside an uploaded ZIP archive without unpacking it into separate S3 objects. Complete Use an S3 SDK first.
Interfaces and permissions
An annotation is attached to a specific parent object version. Each annotation body must be valid UTF-8 text between 1 byte and 1 MiB, and each parent version accepts at most 1,000 annotation names. Updating or deleting an annotation leaves the parent object’s body, ETag and Last-Modified timestamp unchanged.
Operation
SigV4-signed HTTP request
Required IAM action
Create or replace
PUT /attachments/<key>?annotation=&annotationName=labels.json
s3:PutObjectAnnotation
Read body
GET /attachments/<key>?annotation=&annotationName=labels.json
Standard object actions (s3:GetObject, s3:PutObject) do not grant annotation access. Pass versionId in the query string to target a historical version, or x-amz-object-if-match on PUT/DELETE to require a matching parent ETag. Annotation bodies inherit the parent object’s server-side encryption mode.
To read or list members inside a ZIP archive stored as an S3 object, include header x-minio-extract: true:
Read or stat a member: GET or HEAD /attachments/demo.zip/readme.txt with x-minio-extract: true.
List archive members: GET /attachments?list-type=2&prefix=demo.zip/ with x-minio-extract: true.
ZIP extraction reads directly from the parent object snapshot without persisting member objects or an index table. It supports Store and Deflate compression (plus bounded ZIP64), up to 10,000 central-directory entries, and up to 256 MiB per uncompressed member. Range and partNumber requests on ZIP members are not supported.
Complete Python example
Because standard S3 SDKs do not have built-in methods for ?annotation or x-minio-extract, sign the requests with botocore.auth.SigV4Auth. Save the script below as ~/.local/share/silo-tutorial/extensions.py:
importhashlibimportioimportjsonimportosimportsslimporturllib.requestimportzipfilefromurllib.parseimportquote,urlencodeimportboto3frombotocore.authimportSigV4Authfrombotocore.awsrequestimportAWSRequestfrombotocore.configimportConfigendpoint=os.environ["SILO_ENDPOINT"].rstrip("/")ca=os.environ["AWS_CA_BUNDLE"]region="us-east-1"session=boto3.Session(profile_name="silo-admin",region_name=region)credentials=session.get_credentials().get_frozen_credentials()context=ssl.create_default_context(cafile=ca)defsigned_request(method,key,query=None,body=None,headers=None):url=endpoint+"/attachments/"+quote(key,safe="/")ifqueryisnotNone:url+="?"+urlencode(query)request_headers=dict(headersor{})request_headers["x-amz-content-sha256"]=hashlib.sha256(bodyorb"").hexdigest()signed=AWSRequest(method=method,url=url,data=body,headers=request_headers)SigV4Auth(credentials,"s3",region).add_auth(signed)prepared=signed.prepare()request=urllib.request.Request(prepared.url,data=body,headers=dict(prepared.headers),method=method)withurllib.request.urlopen(request,context=context,timeout=60)asresponse:returnresponse.status,response.read()s3=session.client("s3",endpoint_url=endpoint,verify=ca,config=Config(signature_version="s3v4",s3={"addressing_style":"path"}),)parent="extensions/invoice.txt"s3.put_object(Bucket="attachments",Key=parent,Body=b"invoice 1001\n")query={"annotation":"","annotationName":"labels.json"}body=json.dumps({"invoice_id":1001,"status":"paid"}).encode("utf-8")print(signed_request("PUT",parent,query,body,{"Content-Type":"application/json"})[0])print(signed_request("GET",parent,query)[1].decode("utf-8"))print(signed_request("GET",parent,{"annotation":""})[1].decode("utf-8"))print(signed_request("DELETE",parent,query)[0])archive=io.BytesIO()withzipfile.ZipFile(archive,"w",compression=zipfile.ZIP_DEFLATED)asoutput:output.writestr("readme.txt","hello from ZIP\n")s3.put_object(Bucket="attachments",Key="demo.zip",Body=archive.getvalue())print(signed_request("GET","demo.zip/readme.txt",headers={"x-minio-extract":"true"})[1].decode("utf-8"))print(signed_request("HEAD","demo.zip/readme.txt",headers={"x-minio-extract":"true"})[0])print(signed_request("GET","",{"list-type":"2","prefix":"demo.zip/"},headers={"x-minio-extract":"true"})[1].decode("utf-8"))
The script prints the PUT status (200), the annotation JSON, the annotation list XML, the DELETE status (204), the extracted hello from ZIP member content, the HEAD status (200), and the ListObjectsV2 XML for demo.zip/. See Annotations and ZIP extraction for full protocol rules and error codes.
6 - Multipart, Object Lock and STS
Multipart uploads, retention and legal hold, and temporary credentials.
Note
Multipart uploads, S3 bucket notifications and IAM service accounts are Supported MVP features. Object Lock (retention and legal hold), the silo_api SQL transactional outbox and Basic AssumeRole STS are Preview features.
This tutorial covers five multi-step workflows: multipart uploads with failure cleanup, Object Lock retention and legal hold, S3 bucket webhook notifications, a transactional SQL outbox committed with an object, and service accounts / Basic AssumeRole STS credentials. Complete Use an S3 SDK first.
Multipart uploads and failure cleanup
Every multipart part except the final part must be at least 5 MiB, and the assembled object must fit within the store’s maximum object size (256 MiB by default, up to 1 GiB if configured at initialization).
The script below uploads a 5 MiB part and a short final part, lists the uploaded parts, completes the upload in part-number order, and aborts the upload in finally if completion did not succeed:
In addition to s3:PutObject and s3:GetObject, application policies need s3:AbortMultipartUpload for cleanup and s3:ListMultipartUploadParts to list parts (plus s3:ListBucketMultipartUploads to list active uploads in a bucket). Because a process crash can skip finally, also configure an AbortIncompleteMultipartUpload lifecycle rule (see Versioning).
Object Lock, retention and legal hold
Enabling Object Lock when creating a bucket also enables versioning. The script below creates lock-demo with 1 day of default GOVERNANCE retention, writes a version, extends its retention to 2 days, enables legal hold, verifies that deleting the version returns AccessDenied, and then clears the legal hold:
importbase64importhashlibimportosfromdatetimeimportdatetime,timedelta,timezoneimportboto3frombotocore.configimportConfigfrombotocore.exceptionsimportClientErrorsession=boto3.Session(profile_name="silo-admin",region_name="us-east-1")s3=session.client("s3",endpoint_url=os.environ["SILO_ENDPOINT"],verify=os.environ["AWS_CA_BUNDLE"],config=Config(signature_version="s3v4",s3={"addressing_style":"path"}),)bucket,key="lock-demo","retained.txt"s3.create_bucket(Bucket=bucket,ObjectLockEnabledForBucket=True)s3.put_object_lock_configuration(Bucket=bucket,ObjectLockConfiguration={"ObjectLockEnabled":"Enabled","Rule":{"DefaultRetention":{"Mode":"GOVERNANCE","Days":1}},},)body=b"retain this version\n"created=s3.put_object(Bucket=bucket,Key=key,Body=body,ContentMD5=base64.b64encode(hashlib.md5(body,usedforsecurity=False).digest()).decode("ascii"),)version=created["VersionId"]s3.put_object_retention(Bucket=bucket,Key=key,VersionId=version,Retention={"Mode":"GOVERNANCE","RetainUntilDate":datetime.now(timezone.utc)+timedelta(days=2),},)s3.put_object_legal_hold(Bucket=bucket,Key=key,VersionId=version,LegalHold={"Status":"ON"})print(s3.get_object_retention(Bucket=bucket,Key=key,VersionId=version)["Retention"])print(s3.get_object_legal_hold(Bucket=bucket,Key=key,VersionId=version)["LegalHold"])try:s3.delete_object(Bucket=bucket,Key=key,VersionId=version)exceptClientErroraserror:iferror.response["Error"]["Code"]!="AccessDenied":raiseprint("Protected version deletion denied")else:raiseAssertionError("Protected version was unexpectedly deleted")s3.put_object_legal_hold(Bucket=bucket,Key=key,VersionId=version,LegalHold={"Status":"OFF"})
Calling delete_object without VersionId creates a delete marker without removing the protected version. Bypassing GOVERNANCE retention requires the explicit bypass header and s3:BypassGovernanceRetention; active COMPLIANCE retention cannot be bypassed. The silo_api SQL interface enforces retention and legal hold on mutations and provides no governance bypass.
S3 bucket event notifications
To send S3 request-path events to an HTTPS webhook receiver, configure the same webhook target ID (APP) in /etc/default/silo on every writable gateway and restart the gateways:
S3 webhook delivery runs asynchronously after S3 HTTP requests commit; receivers must tolerate retries and duplicates. Direct SQL writes through silo_api do not trigger S3 bucket notifications.
Commit an SQL outbox with the object
When an event must commit or roll back atomically with a business row and an object, write to an application-owned outbox table in the same Read Committed SQL transaction (continuing the app_sql setup from Objects from SQL):
An application worker polls app_demo.outbox, delivers the event idempotently by event_id, and sets delivered_at.
Service accounts and temporary STS identities
To issue a scoped service account under app-s3 without sharing the parent user’s secret key:
(umask077set -o noclobber
mcli_pg --json admin user svcacct add pg-admin app-s3 --name attachments-service > "$SILO_CLIENT_CONFIG/attachments-service.json")mcli_pg admin user svcacct list pg-admin app-s3
To request 15-minute (900-second) temporary credentials over Basic AssumeRole STS, sign AssumeRole with an ordinary IAM user (silo-app). Service accounts and existing STS credentials cannot call Basic AssumeRole, and lifetimes below 900 seconds are rejected:
The inline session Policy further narrows the parent user’s effective permissions; it never expands them. RoleArn is accepted for S3/STS wire compatibility and does not reference an external AWS IAM role.