Skip to main content

Media upload and music

Upload​

InitiateUploadUseCase inserts media.media_object in a pending state and returns a presigned R2 PUT. The client uploads bytes directly to R2. CompleteUploadUseCase checks the object and marks the row ready. Presign TTL is MEDIA_PRESIGN_TTL_MINUTES. Pending rows older than MEDIA_PENDING_TTL_HOURS are removed by PendingUploadCleanupJob.

There is no outbox for "upload completed". Feed learns about media when the client creates a post that references the media id, and when reconciliation runs. MediaReconciliationJob compares feed usage (FeedMediaUsageHttpAdapter) with stored objects and writes media_reconciliation_job_runs plus item logs. Orphans are an ops concern, not a user-facing error.

Public URLs are built from SHARED_MEDIA_PUBLIC_BASE_URL. The bucket name and keys (MEDIA_R2_*) are secrets.

Music​

Search and trending fan out to Apple Music, iTunes, Deezer, and Audius through provider adapters. Redis caches search results and enforces provider rate limits, including the Apple developer token endpoint. Saved tracks are music_saved_tracks plus music_tracks and external reference rows. CatalogIngestJob fills the catalog. A provider outage should degrade search, not uploads: the two paths share a service process but not a transaction.

Filter presets live in filter_catalog and are listed by ListFiltersUseCase. They are reference data, safe to cache.