Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new JavaScript example script demonstrating the chunked FileUpload workflow against the Cablecast API, and documents how to run it from the repository README.
Changes:
- Add
js/file-upload.mjsexample that creates an upload job, uploads segments via multipart, completes the upload, and polls for processing state. - Document the new script, expected workflow steps, and usage in
README.md.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| README.md | Adds usage/docs for the new file upload example script and its API workflow. |
| js/file-upload.mjs | New end-to-end chunked upload example covering job creation, segment upload, completion, and status polling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
js/file-upload.mjs
Outdated
Comment on lines
+33
to
+36
| const SERVER_BASE_URL = 'https://eng-demo.cablecast.tv'; | ||
| const USERNAME = 'admin'; | ||
| const PASSWORD = process.env.CABLECAST_PASSWORD ?? 'yourpassword'; | ||
|
|
Comment on lines
+38
to
+40
| const filePath = process.argv[2]; | ||
| const destinationStoreId = parseInt(process.argv[3] || '11', 10); | ||
|
|
Comment on lines
+48
to
+51
| const fileName = basename(filePath); | ||
| const fileBuffer = readFileSync(filePath); | ||
| const fileSize = statSync(filePath).size; | ||
| const totalSegments = Math.ceil(fileSize / CHUNK_SIZE); |
js/file-upload.mjs
Outdated
| { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Authorization': `Basic ${btoa(`${USERNAME}:${PASSWORD}`)}`, |
README.md
Outdated
Comment on lines
+22
to
+29
| 1. Create an upload job (`POST /v1/fileuploads`) | ||
| 2. Upload the file in 5 MB segments (`POST /v1/fileuploads/{id}/upload`) | ||
| 3. Mark the upload complete (`PUT /v1/fileuploads/{id}`) — this creates an Asset and links it to the destination file store | ||
| 4. Poll until the server finishes processing the file | ||
|
|
||
| Usage: `node file-upload.mjs <path-to-file> [destination-store-id]` | ||
|
|
||
| The destination store ID defaults to `11`. Use `GET /v1/filestores` to list available stores on your system. |
Comment on lines
+113
to
+116
| console.log('Waiting for server to process file...'); | ||
| const maxWaitMs = 5 * 60 * 1000; // 5 minutes | ||
| const pollIntervalMs = 3000; | ||
| const startTime = Date.now(); |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
09a8ecf to
b82da63
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
js/file-upload.mjsdemonstrating the full chunked FileUpload API workflowRelated
Test plan
node file-upload.mjs <path-to-file> 11against eng-demo🤖 Generated with Claude Code