Dyrected
Examples & RecipesRecipe Library

Create a media upload collection

Enable file uploads and capture accessible metadata in a dedicated media collection.

This generated recipe is review-ready source material. Use it from the runtime where it appears in the sidebar and search results.

Enable file uploads and capture accessible metadata in a dedicated media collection.

Use this when

  • let editors upload images
  • create a media library
  • store uploaded files
  • add image uploads to my project

Dyrected concepts

upload, StorageAdapter, media

Additional packages: No additional packages.

Decisions and cautions

Use this recipe only when its runtime matches the project you are documenting or building. Cloud recipes must stay inside the managed content backend boundary. Self-hosted recipes may use the server runtime, database, hooks, and infrastructure you control.

Complete recipe

This is the canonical source compiled and behavior-tested by @dyrected/knowledge.

import { defineCollection, defineTextField, defineTextareaField } from "@dyrected/core";

export const Media = defineCollection({
  slug: "media",
  upload: {
    allowedMimeTypes: ["image/jpeg", "image/png", "image/webp"],
    maxFileSize: 10 * 1024 * 1024,
  },
  fields: [
    defineTextField({ name: "alt", label: "Alternative text", required: true }),
    defineTextareaField({ name: "caption", label: "Caption" }),
  ],
});

On this page

Dyrected| Cloud

Get your backend ready in minutes

Use a managed database, storage, APIs, and admin dashboard without setting up the infrastructure yourself.

Set Up My Backend