Working with Assets
Manage uploaded files, automate asset processing, and serve optimized content using Cortado's built-in tools.
Assets
Storage
Uploading and Receiving Files
Cortado makes it simple to accept file uploads through POST routes. Whether you're handling images, PDFs, or video content, the request parsing layer supports multipart form data and large payloads out of the box. You can define a dedicated upload route and attach middleware to validate, rename, or scan the file before saving.
Uploaded files are accessible immediately, and you can choose to store them locally, on external services like S3, or within a CDN pipeline for instant delivery.
Automating Asset Processing
Once an asset is uploaded, Cortado allows you to run post-processing steps tailored to the file type. You might want to resize images, generate thumbnails, extract metadata, or apply compression.
Common use cases include:
Resizing and optimizing images on upload
Scanning PDFs for text content or preview pages
Tagging files with user or project identifiers
Generating slugs, titles, or categories from metadata
These steps can run in sequence using middleware chains or async job queues.
Securing Access to Files
Not all assets should be publicly accessible. Cortado provides flexible patterns for protecting files based on authentication tokens, user roles, or time-based access logic. You can create signed URLs that expire after a certain time or restrict access based on user subscriptions.
Example: A private image file might only be visible to a user who purchased a product, with access tied to a signed request.
This ensures sensitive files are handled securely while maintaining performance.
Organizing and Querying Assets
Cortado makes it easy to structure assets based on business logic. Files can be stored in a project-based folder system, tagged by user or upload context, and queried through custom API routes. You can also expose asset metadata to clients, including size, MIME type, upload date, or linked user info.
Designing a clear asset schema upfront helps you avoid chaos as your library grows.
Delivering Content Efficiently
To optimize delivery, assets can be served through cached routes, CDN-backed URLs, or lazy-loaded in client apps. You can include width/height parameters for responsive image delivery, or serve compressed video assets depending on bandwidth.
Best practices for asset delivery:
Use caching headers on public routes
Serve images in next-gen formats like WebP
Link large files only after permission checks
This ensures the frontend experience is fast without compromising control.
Scaling Asset Workflows
As your product grows, so will your asset library. Cortado supports modular storage backends, letting you migrate from local dev storage to scalable cloud services without rewriting your core upload logic. You can batch process assets in background jobs or connect external processing pipelines if needed.
Combined with real-time event triggers (e.g. on upload complete), this makes Cortado a flexible foundation for asset-heavy applications like media platforms, SaaS tools, or design apps.
Last updated on
Oct 4, 2025