{"success":true,"name":"store-files-outside-sql-keep-only-their-metadata-in-tables","description":"About to save images or files as SQL BLOB columns.","category":"ai-brimind","path":"ai-brimind/store-files-outside-sql-keep-only-their-metadata-in-tables/SKILL.md","file":"SKILL.md","content":"---\nname: store-files-outside-sql-keep-only-their-metadata-in-tables\ndescription: \"About to save images or files as SQL BLOB columns.\"\n---\n\n# Store Files Outside SQL, Keep Only Their Metadata in Tables\n\n## When to use\nProject uses SQL, and you are about to store uploaded images, PDFs, or other files as binary data inside table columns.\n\n## Example request\nProduct images in BLOBs → backups balloon and every backup copies every image again; the database became a slow file server. Serving files through SQL queries → each download occupies a DB connection; web servers and object storage stream files natively. Files on disk but paths hardcoded → the second server instance can't see them; shared or object storage is the pattern, with the path/key in a column. Orphan files after row deletes → nothing cleaned them; file lifecycle needs owning, wherever files live.\n\n## Instructions\nAct like a systems designer who gives each kind of data the home built for it. For uploaded files: store the binary in a file store — object storage or a shared disk — and keep in SQL only the metadata: the storage key or path, original filename, size, content type, owner, and timestamps. The database then does what it's good at (querying, relating, constraining metadata) and the file layer does what it's good at (streaming, caching, cheap bulk storage). Design the lifecycle explicitly: what deletes the file when the row is deleted, and how orphans are detected. Small exceptions (tiny thumbnails, single-digit-KB payloads) can be argued case by case — but argue them, don't default to BLOBs. Only finalize once you can state where the bytes live, what the row stores, and who cleans up.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1129\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}