The upload() function
upload() takes three arguments: segments, a manifest string, and options.
keyServerUrl must include the /keys path — e.g., https://your-worker.workers.dev/keys, not just the base URL. The uploader appends /:contentId when fetching the content key.What happens internally
Preparing segments
The uploader expects pre-segmented HLS content —.ts segment files and a .m3u8 manifest. It does not convert raw video to HLS.
Server-side (ffmpeg):
<input>:
Pass the original, unmodified manifest to
upload(). The uploader rewrites it internally — adding EXT-X-KEY tags that point to your key server.SegmentInput format
Verify playback
After uploading, verify the content plays back correctly using the Player:Authentication
Theauth callback is called twice:
- Key fetch: The uploader sends
Authorization: Bearer <token>when fetching the content key - Presign requests: The uploader sends the same header when requesting presigned URLs