feat: S3 upload pipeline for APNG animated cards #198

Closed
opened 2026-04-08 00:19:32 +00:00 by cal · 1 comment
Owner

Problem

card_storage.py only handles PNG uploads. The animated card endpoint (/animated) does not trigger any S3 upload. T3 and T4 variant cards will have static PNG image_url values but no animated versions cached on S3/CDN.

Currently animated cards are rendered on-demand, which works but is expensive (12–24 Playwright screenshots per card). If animated cards need to be served at scale (e.g., in collection views or Discord embeds), on-demand rendering won't scale.

Fix

Extend card_storage.py to support APNG uploads with path pattern:
cards/cardset-{csid:03d}/player-{pid}/v{variant}/{card_type}card.apng

Wire the animated endpoint to trigger a background S3 upload (same pattern as static card renders).

Impact

Not blocking for initial launch (on-demand works), but needed for CDN caching and scale. Becomes important if animated cards appear in collection views or notifications.

## Problem `card_storage.py` only handles PNG uploads. The animated card endpoint (`/animated`) does not trigger any S3 upload. T3 and T4 variant cards will have static PNG `image_url` values but no animated versions cached on S3/CDN. Currently animated cards are rendered on-demand, which works but is expensive (12–24 Playwright screenshots per card). If animated cards need to be served at scale (e.g., in collection views or Discord embeds), on-demand rendering won't scale. ## Fix Extend `card_storage.py` to support APNG uploads with path pattern: `cards/cardset-{csid:03d}/player-{pid}/v{variant}/{card_type}card.apng` Wire the animated endpoint to trigger a background S3 upload (same pattern as static card renders). ## Impact Not blocking for initial launch (on-demand works), but needed for CDN caching and scale. Becomes important if animated cards appear in collection views or notifications.
Claude added the
ai-working
label 2026-04-08 15:01:18 +00:00
Claude added
ai-pr-opened
and removed
ai-working
labels 2026-04-08 15:04:51 +00:00
Collaborator

PR #210 opened: #210

Approach: Added build_apng_s3_key, upload_apng_to_s3, and upload_variant_apng to card_storage.py following the existing PNG upload pattern. Wired get_animated_card to trigger upload_variant_apng as a background task on each new render (cache miss only; ?tier= dev previews skipped).

Note: no animated_url DB column exists yet — the upload goes to S3 but there's no URL stored back to the DB. A follow-up migration would be needed to expose animated_url via the API.

PR #210 opened: https://git.manticorum.com/cal/paper-dynasty-database/pulls/210 **Approach:** Added `build_apng_s3_key`, `upload_apng_to_s3`, and `upload_variant_apng` to `card_storage.py` following the existing PNG upload pattern. Wired `get_animated_card` to trigger `upload_variant_apng` as a background task on each new render (cache miss only; `?tier=` dev previews skipped). Note: no `animated_url` DB column exists yet — the upload goes to S3 but there's no URL stored back to the DB. A follow-up migration would be needed to expose `animated_url` via the API.
cal closed this issue 2026-04-08 15:25:41 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/paper-dynasty-database#198
No description provided.