Operations manual

Operate · 06

Media library

The media library is the shared asset source for the storefront, Content Studio, journal, banners and Email Studio. One record should serve every surface that needs the same image.

OperateMediaAssetsReviewed November 2026
The Perfumz media library in the staff console
Media libraryMedia

The library

/dashboard/media/ provides a searchable grid, folders, asset detail, alt text, tags, dimensions and usage information. Uploads are available from the library and from the Content Studio, email and banner inspectors through the media picker.

Supported asset roles include portrait, landscape, gallery, poster, video and document. Use the role that matches the surface; the product page and collection cards expect specific crops.

Folders and metadata

Create a folder for a campaign, product line or editorial story before uploading. Renaming a folder keeps its assets; deleting a folder moves its assets rather than deleting them. The quick menu exposes edit, copy URL, download, favourite and delete actions.

FieldUse
NameHuman-readable label used in search and the picker.
Alt textAccessible description; required for meaningful storefront images.
TagsComma-separated search terms.
FolderGrouping for campaigns and product families.
RolePortrait, landscape, gallery, poster, video or document.

Upload limits

Django accepts files up to 25 MB in memory and Nginx allows a 30 MB request body. Product photography should be compressed before upload; the browser does not resize originals. The media API returns up to 80 matching images for the picker.

# Check the effective limits
.venv/bin/python - <<'PY'
from django.conf import settings
print(settings.DATA_UPLOAD_MAX_MEMORY_SIZE)
print(settings.FILE_UPLOAD_MAX_MEMORY_SIZE)
PY

Storage and serving

Two storage modes are supported. Local disk is the default: Nginx serves /media/ from /srv/perfumz/media/, while Django serves it in development. S3 + CloudFront is enabled with USE_S3=1: media goes to the media/ prefix, collected static to static/, and CloudFront delivers both.

AssetLocal modeS3 / CloudFront mode
Public media/media/<key> via Nginxhttps://CLOUDFRONT_DOMAIN/media/<key>
Static/static/<key> via Nginxhttps://CLOUDFRONT_DOMAIN/static/<key>
Private media/media/private/<key> via authenticated Django viewLocal authenticated URL (not uploaded to S3)
USE_S3=1
AWS_STORAGE_BUCKET_NAME=perfumz-media
AWS_S3_REGION_NAME=me-central-1
CLOUDFRONT_DOMAIN=cdn.perfumz.com
CLOUDFRONT_DISTRIBUTION_ID=E123EXAMPLE
CLOUDFRONT_SIGNED_URLS=1
CLOUDFRONT_KEY_ID=K123EXAMPLE
CLOUDFRONT_PRIVATE_KEY_PATH=/etc/perfumz/cloudfront-private.pem

The local fallback remains production-ready when Nginx serves MEDIA_ROOT. S3 is optional for public assets, but backups always require the private S3 backup bucket.

Deduplication and private media

The upload flow computes a SHA-256 checksum and skips a duplicate file in the same visibility class. Private uploads are stored through the private storage adapter; public uploads through the media adapter. A private asset can be moved to public (or back) from the media drawer or Django admin, and the old public key is queued for CDN invalidation.

Private local files are never exposed by the public Nginx /media/ alias. Nginx proxies /media/private/ to Django, which checks staff or uploader access and returns Cache-Control: private, no-store.

CDN management

The media dashboard shows the active backend, CloudFront host, signed-URL state and pending invalidations. Staff can purge one public asset from the drawer or the whole media library from the header. Invalidation requests are durable database records, processed by the jobs timer or immediately from the CDN admin.

python manage.py invalidate_cdn --path /media/2026/11/bottle.jpg
python manage.py process_cdn_invalidations
python manage.py run_scheduled_jobs --only process_cdn_invalidations

Media backups

create_backup writes media-<timestamp>.tar.gz for local media. S3 media is not copied into that archive; enable bucket versioning plus a replication/backup job for object storage. Restore local media only while the application is stopped or in maintenance mode, then verify a sample image and a product page.

gunzip -c backups/db-<timestamp>.sql.gz | sudo -u postgres psql perfumz
tar -xzf backups/media-<timestamp>.tar.gz -C /srv/perfumz

Troubleshooting

SymptomCauseFix
Upload returns 413Nginx body limit or Django upload limit exceeded.Reduce the file or raise client_max_body_size and the Django limits together.
Image 404 after uploadMedia alias, S3 key or permissions are wrong.Check the Nginx alias or the bucket object key and CloudFront origin path.
Image URL uses the S3 hostnameCloudFront is not configured or USE_S3 changed without a restart.Set CLOUDFRONT_DOMAIN and restart the service.
Private asset cannot be openedYou are anonymous or not the uploader/staff.Sign in as staff or the uploader; private media stays local and requires that authenticated route.
CDN purge says not configuredDistribution ID or AWS credentials are missing.Set CLOUDFRONT_DISTRIBUTION_ID and credentials/IAM role, then restart.
Deleted asset still rendersThe page or email still references its URL.Purge the CDN path and update the referencing section or email.
Perfumz Operations Manual · English reference · Reviewed November 2026