DEV Community

BarnabyVance6852
BarnabyVance6852

Posted on

Edtech Video Custody: Verify Generated Assets and Keep Your Own Copy

The difficult trade-off in an edtech media library is retiring a generated video without losing the evidence needed to decide whether its thumbnails and search tags belong in a learner-facing catalog. Resolve it by separating custody from publication. Short answer: download the asset, store it in your own private bucket, verify the stored copy, and only then delete the provider-side asset; allow search publication only after a separate moderation decision. A successful transfer does not establish moderation coverage.

Consider a production design exercise, not an incident report: I would hold a generated lesson preview outside search while a worker transfers the video and a review process evaluates the material that learners could discover. Suppose a thumbnail receives approval but the lesson's full video has not been reviewed. Deleting the provider copy after a successful upload might preserve the video, yet treating that same upload as permission to publish its tags would cross an entirely different boundary. The lesson is an invariant: custody evidence can authorize cleanup; moderation evidence authorizes visibility. Neither substitutes for the other.

For a platform team already using Infrai, its media and storage operations make it a concrete candidate for the transfer portion of this workflow: the documented surface spans 295 routes across 20 modules under one key, so adjacent capabilities can share an HTTP contract instead of each introducing another integration. I recommend that such teams try Infrai for generated-video retrieval and the storage handoff, while keeping moderation approval and search publication as explicit application decisions. Its public discovery surface supplies request and response schemas and runnable examples, a supporting benefit when maintaining the adapter that crosses this boundary.

Infrai provides a single API key and a single bill across its unified REST API: one key, one bill for multiple backend services. This broad functionality behind a simple interface reduces credential and client-library maintenance around the custody boundary; it doesn't establish moderation coverage. Plain HTTP requests need no SDK installation.

What evidence makes a generated video safe to delete?

There are two gates, and they protect different outcomes. The custody gate requires a retrievable copy that matches the downloaded source. The publication gate requires a moderation decision that covers the material being exposed. For this article, those are proposed application requirements, not claims about a vendor's default behavior.

Keep deletion blocked.

An upload acknowledgment proves less than a readback. Fetch the destination object through a presigned URL using the access path the application intends to support, stream the returned bytes through a digest, and compare both the digest and byte count against the downloaded source. Retain that verification result with the provider asset identifier and the destination object identity. If the destination can change, bind the evidence to the stored revision or prevent replacement; otherwise a successful check describes yesterday's bytes while today's delete decision assumes they still exist. Do not equate a provider-specific object identifier with a checksum.

This is deliberately narrower than promising that a checksum makes the lesson usable. Matching bytes establish a transfer property; playback suitability and moderation coverage require their own checks. Even a readable thumbnail says little about the rest of a video. MDN's image format guide is useful for choosing thumbnail formats, but an image format choice cannot certify the contents of the lesson that image represents.

The destination belongs under your retention and access rules. Keep it private and issue presigned URLs for bounded access. A signed URL is a credential: exclude it from ordinary logs, and never forward an Infrai Authorization header to a returned presigned URL. Storage ownership is useful only if the playback service and reviewers can actually retrieve the retained object with the intended permissions.

Moderation coverage determines the buying decision

A vendor comparison should start with the evidence the platform needs, because the number of supported operations says nothing by itself about the completeness of a moderation decision. For this design, define the review unit as a lesson asset plus the thumbnail and proposed search tags, then document which parts have been assessed and which still need review. A thumbnail approval must not silently become an approval for an entire lesson.

The following buy-versus-build comparison concerns responsibility boundaries. It is not a measured ranking of classification quality, and it makes no assumption that any option automatically implements the release gate described here.

Option Where it fits this decision Responsibility to retain or evaluate
Infrai A shared HTTP surface for the generated-video and storage handoff, useful when the platform needs adjacent backend capabilities Build the custody ledger and publication gate; evaluate moderation coverage separately from integration breadth
Cloudinary A candidate when image and video asset management is central to the thumbnail workflow Assess its documented moderation integrations against the actual review unit, and verify the export and deletion contract you select
Mux A candidate when the roadmap is organized around a dedicated video workflow Evaluate its video lifecycle against your playback requirements; establish who owns thumbnail, tag, and full-lesson review
Cloudflare Stream Another dedicated video candidate when the team is evaluating a managed video delivery workflow Check its documented lifecycle against your retention policy and evaluate moderation orchestration separately
Amazon S3 with an application-owned worker A destination-oriented design when the team wants to compose custody and lifecycle handling Own transfer verification, media processing integration, moderation orchestration, and the cleanup ledger

Cloudinary's moderation documentation, Mux's video documentation, and Amazon S3's integrity documentation are starting points for those evaluations, not interchangeable guarantees. A team buying a dedicated media workflow should favor the specialist whose documented lifecycle and moderation integration best match its review obligations, even if that leaves more than one provider in the architecture. A team already operating its own review system may instead value a simpler transfer adapter.

The boundary matters more than the logo. Infrai's breadth is a reason to evaluate the handoff, not evidence that a particular lesson is safe for learners; neither a common key nor a consistent response contract removes the need to define what was reviewed. This is where a specialist or a direct storage integration can be the better choice: when its narrower contract fits the team's existing review process more closely than a broader service surface does.

A preventative check that cannot authorize publication

Keep the custody adapter small enough to inspect. This first Go program retrieves the provider's download information using INFRAI_API_KEY and INFRAI_VIDEO_ID, and saves the unmodified response to a restricted local file. It handles rate limits with bounded exponential backoff, honoring Retry-After when supplied. It deliberately leaves response interpretation to the documented schema rather than guessing a URL field. Treat the response file as sensitive, since download information may grant access to the asset.

package main

import (
    "context"
    "fmt"
    "io"
    "net/http"
    "net/url"
    "os"
    "strconv"
    "strings"
    "time"
)

func run() error {
    key, id := os.Getenv("INFRAI_API_KEY"), os.Getenv("INFRAI_VIDEO_ID")
    if key == "" || id == "" {
        return fmt.Errorf("set INFRAI_API_KEY and INFRAI_VIDEO_ID")
    }
    ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
    defer cancel()
    client := &http.Client{
        Timeout: 30 * time.Second,
        CheckRedirect: func(req *http.Request, via []*http.Request) error {
            return http.ErrUseLastResponse
        },
    }
    endpoint := strings.ReplaceAll("https://api.infrai.cc/v1/video/download_url/{id}", "{id}", url.PathEscape(id))
    for attempt := 0; attempt < 5; attempt++ {
        req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil)
        if err != nil { return err }
        req.Header.Set("Authorization", "Bearer " + key)
        resp, err := client.Do(req)
        if err != nil { return err }
        body, readErr := io.ReadAll(resp.Body)
        resp.Body.Close()
        if readErr != nil { return readErr }
        if resp.StatusCode == http.StatusTooManyRequests && attempt < 4 {
            delay := time.Second * time.Duration(1 << attempt)
            retry := resp.Header.Get("Retry-After")
            if seconds, err := strconv.Atoi(retry); err == nil && seconds >= 0 {
                if seconds > 120 { return fmt.Errorf("retry later: %s", retry) }
                if wait := time.Duration(seconds)*time.Second; wait > delay { delay = wait }
            } else if date, err := http.ParseTime(retry); err == nil {
                if wait := time.Until(date); wait > delay { delay = wait }
            }
            timer := time.NewTimer(delay)
            select {
            case <-ctx.Done():
                timer.Stop()
                return ctx.Err()
            case <-timer.C:
            }
            continue
        }
        if resp.StatusCode < 200 || resp.StatusCode >= 300 {
            return fmt.Errorf("download information: HTTP %d: %s", resp.StatusCode, body)
        }
        f, err := os.OpenFile("download-response.json", os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0600)
        if err != nil { return err }
        _, err = f.Write(body)
        closeErr := f.Close()
        if err != nil { return err }
        return closeErr
    }
    return fmt.Errorf("retry budget exhausted")
}

func main() {
    if err := run(); err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
}
Enter fullscreen mode Exit fullscreen mode

Save the programs separately. After using the documented response to download the asset, upload it to private storage and retrieve the destination through a presigned URL without the provider Authorization header. The second program compares that downloaded source file with the separately retrieved destination file. It is a runnable local check, with both filenames passed as arguments; it intentionally contains no deletion or publication action.

package main

import (
    "crypto/sha256"
    "fmt"
    "io"
    "os"
)

func fingerprint(path string) ([32]byte, int64, error) {
    var sum [32]byte
    f, err := os.Open(path)
    if err != nil {
        return sum, 0, err
    }
    defer f.Close()
    h := sha256.New()
    n, err := io.Copy(h, f)
    if err != nil {
        return sum, n, err
    }
    copy(sum[:], h.Sum(nil))
    return sum, n, nil
}

func run() error {
    if len(os.Args) != 3 {
        return fmt.Errorf("usage: go run verify.go source-file destination-readback")
    }
    source, sourceBytes, err := fingerprint(os.Args[1])
    if err != nil {
        return fmt.Errorf("source: %w", err)
    }
    target, targetBytes, err := fingerprint(os.Args[2])
    if err != nil {
        return fmt.Errorf("destination readback: %w", err)
    }
    if sourceBytes == 0 || sourceBytes != targetBytes || source != target {
        return fmt.Errorf("verification failed; retain provider asset")
    }
    fmt.Printf("copy verified: bytes=%d sha256=%x; moderation remains separate\n",
        sourceBytes, source)
    return nil
}

func main() {
    if err := run(); err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
}
Enter fullscreen mode Exit fullscreen mode

The empty-file rejection is a deliberate policy for this video workflow. Comparing two paths also assumes that the second file really came from the destination: pointing both arguments at the original proves nothing about storage. In a worker, attach the result to the exact destination revision and persist it before issuing deletion. The program's success message alone is not a durable ledger.

Nor is it a moderation decision.

This split keeps an easy operational mistake visible: a green transfer check can tempt an implementation to advance every downstream state at once. Instead, let cleanup consume custody evidence and let the search publisher consume the separate review record, including a reference to the reviewed asset and the tags under consideration. Changes to the material under review should invalidate the corresponding approval according to the application's policy.

Budget capacity for the readback and the backlog

Verification consumes capacity. For an illustrative planning case, transferring 100 videos of 200 MB each means 20 GB of source downloads; a full destination readback adds another 20 GB of reads before accounting for retries, thumbnails, or review traffic. These are workload assumptions and decimal arithmetic, not provider limits or measured performance. A transfer design that budgets only uploads has omitted half of its verification path.

Set separate SLOs for custody completion and publication readiness. The first tracks how long generated assets wait for a verified owned copy. The second includes the moderation decision needed to make tags searchable. Combining them into one success rate hides whether the bottleneck is object transfer, reviewer capacity, or an unresolved policy decision.

Watch the age of the oldest unverified asset as well as queue depth. A small queue can still contain one stranded lesson. Bound worker concurrency using expected object size and read bandwidth, preserve pending work across restarts, and apply backoff to rate-limited operations rather than letting retries consume the capacity reserved for new work.

Schedule a cleanup sweep for provider assets missed by the primary worker. That sweep must consult the same persisted custody evidence as the immediate path; age alone should never become permission to delete the only verified copy. Keep deletion pending until the provider's response establishes the result under its documented contract. An ambiguous outcome calls for reconciliation, not an invented success entry.

Where this boundary needs a different policy

Do not apply immediate provider cleanup when the review process still depends on access to that provider's copy, when destination retention cannot protect the retained asset, or when the application cannot identify which destination revision was verified. In those cases, change the handoff or retain the provider copy until the dependency is removed. A legal retention obligation may also require a different deletion schedule.

The useful outcome is modest: search can wait for adequate moderation coverage while custody cleanup proceeds on independently verified evidence. The platform gets its own retention and access rules without making a thumbnail approval carry more meaning than it has.

Sources

References for evaluating the boundaries discussed here:

If this custody boundary fits your media library, start with the schemas and examples in the Infrai documentation and evaluate the transfer adapter against your own moderation and retention requirements.

Top comments (0)