management: product image upload to R2 #44
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Every mockup renders products at a 1:1 contained aspect ratio, and
apps/store/next.config.tssetsimages.unoptimized— so whatever URL lands ininventory.imagesis served verbatim. Today both inventory forms accept pasted URL strings only (add-inventory-modal.tsx,inventory-edit-form.tsx), andscripts/seed-demo.mtsusesplacehold.co. There is no upload path, so real product photos depend on the operator hosting files somewhere else. The design cannot ship with real imagery until this exists.Change
lib/storage/r2.tsalready has the whole mechanism inuploadReceipt(file, "order" | "purchase")— S3 client, MIME allow-list, size caps,${R2_PUBLIC_URL}/${key}return. Generalise the key prefix and kind rather than writing a second uploader: accept aproductkind writing toproducts/{YYYY}/{MM}/{uuid}{ext}, keep receipts on their existing prefix so nothing already stored moves. Images only for this kind — no PDF branch, and hold the 5 MB image cap.app/api/[[...route]]/uploads.ts, whosetypeis currently restricted toorder|purchase.lib/uploads.ts, then replace the URL-row inputs in both inventory forms with a file picker that appends the returned public URL intoimages. Keep manual URL entry working — items already reference external URLs.lib/mcp/tools/images.tsgains the product kind alongsideupload_receipt.Acceptance
An operator uploads a photo in the stok form and the item renders it on the storefront after the next deploy, with no external hosting. Receipt uploads are byte-for-byte unaffected: same prefix, same caps, same PDF handling. A non-image file and an oversized file are both rejected with a readable message. Cover the kind→prefix mapping and the rejection paths in
vitest.