Storage

Connect applications

Storage works with the most used object storage command-line tools and SDKs. To connect, you need three things: the endpoint, the region and an access key created in the console.

Before you start

  1. Create a bucket from the Storage menu in the console.
  2. Create an access key for the application and keep its ID and secret. The secret is shown only once.
  3. Pick the access level for what the application does: Read and upload lists, downloads and uploads, but does not delete files; deleting files and changing bucket settings, such as CORS and versioning, require Full.
  4. If you limited the key to some networks, make sure the application connects from one of them.
SettingValue
Endpointhttps://armazem.zenifra.com
Regionbr-sp1
Address of each buckethttps://<bucket>.armazem.zenifra.com

Keep the key in environment variables, never in code. In Zenifra projects, use the project environment variables.

ACCESS_KEY_ID=...
SECRET_ACCESS_KEY=...

AWS CLI

aws configure set aws_access_key_id "$ACCESS_KEY_ID" --profile zenifra
aws configure set aws_secret_access_key "$SECRET_ACCESS_KEY" --profile zenifra
aws configure set default.s3.addressing_style virtual

aws --profile zenifra --endpoint-url https://armazem.zenifra.com --region br-sp1 s3 ls
aws --profile zenifra --endpoint-url https://armazem.zenifra.com --region br-sp1 s3 cp ./photo.png s3://photos/2026/photo.png

JavaScript and TypeScript

npm install @aws-sdk/client-s3 @aws-sdk/lib-storage @aws-sdk/s3-request-presigner
import { GetObjectCommand, PutObjectCommand, S3Client } from '@aws-sdk/client-s3'
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'

const client = new S3Client({
  endpoint: 'https://armazem.zenifra.com',
  region: 'br-sp1',
  credentials: { accessKeyId: process.env.ACCESS_KEY_ID!, secretAccessKey: process.env.SECRET_ACCESS_KEY! },
})

await client.send(new PutObjectCommand({ Bucket: 'photos', Key: '2026/photo.png', Body: file, ContentType: 'image/png' }))

const link = await getSignedUrl(client, new GetObjectCommand({ Bucket: 'photos', Key: '2026/photo.png' }), { expiresIn: 3600 })

PutObjectCommand sends the whole file in a single request. For large files, such as videos and backups, use Upload from @aws-sdk/lib-storage, which splits the upload into parts and sends several at once:

import { createReadStream } from 'node:fs'
import { Upload } from '@aws-sdk/lib-storage'

const upload = new Upload({
  client,
  params: { Bucket: 'videos', Key: '2026/class.mp4', Body: createReadStream('./class.mp4'), ContentType: 'video/mp4' },
  partSize: 8 * 1024 * 1024,
  queueSize: 4,
})
upload.on('httpUploadProgress', ({ loaded, total }) => console.log(loaded, total))
await upload.done()

Python

pip install boto3
import os
import boto3
from botocore.config import Config

client = boto3.client(
    's3',
    endpoint_url='https://armazem.zenifra.com',
    region_name='br-sp1',
    aws_access_key_id=os.environ['ACCESS_KEY_ID'],
    aws_secret_access_key=os.environ['SECRET_ACCESS_KEY'],
    config=Config(s3={'addressing_style': 'virtual'}),
)

client.upload_file('backup.tar.gz', 'backups', '2026/backup.tar.gz')
link = client.generate_presigned_url('get_object', Params={'Bucket': 'backups', 'Key': '2026/backup.tar.gz'}, ExpiresIn=3600)

upload_file already splits files above 8 MB into parts. To change the part size, pass Config=TransferConfig(multipart_chunksize=...) (from boto3.s3.transfer import TransferConfig).

Django

With django-storages, FileField and ImageField write straight to Storage:

pip install django-storages boto3
# settings.py
import os

STORAGES = {
    'default': {
        'BACKEND': 'storages.backends.s3.S3Storage',
        'OPTIONS': {
            'bucket_name': os.environ['ARMAZEM_BUCKET'],
            'endpoint_url': 'https://armazem.zenifra.com',
            'region_name': 'br-sp1',
            'access_key': os.environ['ACCESS_KEY_ID'],
            'secret_key': os.environ['SECRET_ACCESS_KEY'],
            'addressing_style': 'virtual',
            'default_acl': None,
            'file_overwrite': False,
            'querystring_expire': 3600,
        },
    },
    # keep the static files backend you already use, such as WhiteNoise
    'staticfiles': {'BACKEND': 'django.contrib.staticfiles.storage.StaticFilesStorage'},
}

With this setup, files stay private, file.url returns a 1-hour signed link and an upload with a repeated name gets a suffix instead of replacing the previous file.

Other languages and tools

Any S3-compatible SDK or tool works with the same settings: the endpoint https://armazem.zenifra.com, the region br-sp1, and the key ID and secret. If the tool has an addressing style option, use per-bucket addresses (virtual-hosted), not path-style.

A signed link gives access to a single file for a limited time, without exposing the key. Use links to:

  • deliver a file to an end user;
  • receive an upload straight from the user's browser, without passing through your server;
  • share a file by email or chat.

To receive uploads straight from the browser, the bucket needs a CORS rule that allows your site's domain. See the steps in Code examples. A link lasts at most 7 days. In the console, Copy link creates a 7-day download link; on a public file, it copies the public address, which does not expire.

Good practices

  • One key per application. You can revoke one without affecting the others.
  • Limit networks. A key restricted to the application's networks does not work if it leaks.
  • Retry on limits. Above the key's traffic limit, Storage refuses the request with SlowDown (HTTP 503). SDKs already retry with backoff; keep that on.
  • Upload large files in parts. The AWS CLI and boto3's upload_file split large uploads automatically; in JavaScript, use Upload from @aws-sdk/lib-storage. The limit is 20 GB per file.

Common errors

ErrorLikely cause
403 AccessDeniedrevoked key, network not in the key's list, a key access level without the operation (for example, deleting with Read and upload), read-only Storage or an operation that is not allowed, such as making a file public
403 SignatureDoesNotMatchwrong secret, machine clock out of sync or a changed signed link
404 NoSuchBucketthe bucket does not exist or the name is misspelled
404 NoSuchKeythe file does not exist in the bucket
503 SlowDownthe key's traffic limit; retry with backoff

Next steps

Last updated on

On this page