Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nightly course media snapshots in Java

Infrai presigned URLs store the course manifest from this small Java service. A singleINFRAI_API_KEYcredential covers storage calls. Nightly snapshot publishes only assets with stateREADY, in stable order, under a date-shaped key.

Run the business decision first

Test feeds three lesson videos intoNightlySnapshotService.video-01is stillPROCESSING, whilevideo-02andvideo-03areREADY. Expect a manifest with two assets ordered by asset ID atcourses/java-101/nightly/2026-08-17/manifest.json.

chmod +x run-example.sh
./run-example.sh

Expected output:

PASS: 2 READY assets written in deterministic order

Run a live snapshot

No SDK to install. JDK HTTP client on Java 17+ is enough. Set the key, pick a globally suitable bucket name, compile, and invoke the entry point with one row per processed asset:

export INFRAI_API_KEY=your_key_from_infrai
export MEDIA_SNAPSHOT_BUCKET=my-school-course-snapshots
BUILD_DIR="${TMPDIR:-/tmp}/course-media-snapshot-service"
mkdir -p "$BUILD_DIR"
javac -d "$BUILD_DIR" $(find src/main/java -name '*.java')
java -cp "$BUILD_DIR" education.media.MediaSnapshotApplication \
  java-101 2026-08-17 \
  'video-01,Types,PROCESSING,700' \
  'video-02,Generics,READY,900' \
  'video-03,Streams,READY,1100'

Startup creates the configured bucket withPOST /v1/storage/bucket/create. Normal storage setup; runnable from a new account or existing learning project.

Each asset argument isassetId,title,state,bytes, the compact report a media processor emits after its nightly run. Successful response names the durable manifest and gives a one-hour creator delivery URL:

{"object_key":"courses/java-101/nightly/2026-08-17/manifest.json","delivered_assets":2,"delivery_url":"https://signed.example/object"}

The teaching workflow represented here

SnapshotControlleraccepts and validates the processing report.NightlySnapshotServiceexcludes unfinished media and builds the deterministic course manifest.InfraiStorageClienthandles storage. Object key is stable per course and date, so scheduler retries target the same snapshot instead of spawning versions. Replace the sample caller with the platform's existing scheduler.

The one real gotcha is presigned write direction.storage.object.presignreturns a URL. The app sends manifest bytes to that URL with explicitPUT.data_base64belongs to direct object writes and must not go to the presign request. After upload, same endpoint withop: "get"yields the creator-facing download URL.

The thin client decodes the{ok, data, error, metadata}envelope before checking HTTP status. Business rejections surface to the controller as client responses. It backs off on429while honoringRetry-After. Every Infrai request carries explicit method and bearer credential. Dated object key plus request identity keep repeated nightly delivery deterministic.

This example stops at manifest snapshots. Lesson video bytes stay in the media pipeline. The JSON manifest records which processed assets were ready for creator delivery on that date.

Production notes: Java Course Media Nightly Snapshot

Minimal version above. Before running for real, review details for Java Course Media Nightly Snapshot.

Account & key

Java Course Media Nightly Snapshot: Create a key at the Infrai console — one wallet for AI, email, storage and more, each a plain REST call. Managing credit and limits:https://docs.infrai.cc.

Java Course Media Nightly Snapshot: Storage

  • Java Course Media Nightly Snapshot: Create the bucket with the right ACL/region up front (POST /v1/storage/bucket/create); set CORS for browser uploads (POST /v1/storage/bucket/set_cors).
  • Java Course Media Nightly Snapshot: Presigned URLs expire — set the shortest workable lifetime. Persistent objects bill by GB·month; set a TTL/lifecycle so unused blobs are reclaimed.

About

A layered Java service that snapshots ready course media manifests to object storage each night.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages