Skip to content

Drop the multi-step upload; use POST /documents/upload everywhere#2

Merged
specialistvlad merged 3 commits into
mainfrom
single-upload-only
Jun 3, 2026
Merged

Drop the multi-step upload; use POST /documents/upload everywhere#2
specialistvlad merged 3 commits into
mainfrom
single-upload-only

Conversation

@Nick-Belhovskyi

Copy link
Copy Markdown
Contributor

What

The External API removed the multi-step upload (POST /documents → S3 PUTPUT /documents/{id}), leaving a single endpoint: POST /api/documents/upload. This updates the demo (CLI + examples) to use it exclusively.

Changes

  • CLI (cli/cmd/upload.go, cli/api/client.go) — upload always uses the single multipart request; removed the --single-request flag, the 3-step branch, and the now-unused UploadToS3 client method.
  • TypeScript (examples/typescript/upload-and-poll.ts) — single multipart upload via fetch + FormData.
  • Python (examples/python/sync-polling.ipynb) — single multipart upload via httpx; dropped the create / S3 / complete cells.
  • Docs (README.md, cli/README.md) — document only the single upload.

Verification

  • go build ./..., go vet ./..., gofmt -l — all clean.
  • TS / Python examples were not run locally.

Pairs with LexSelect/lexselect#979 (the API change that removed the multi-step routes).

🤖 Generated with Claude Code

The External API removed the multi-step upload (POST /documents -> S3 PUT -> PUT /documents/{id}), leaving the single multipart endpoint POST /documents/upload. The CLI and examples now use it exclusively: the CLI always uses UploadMultipart (removed the --single-request flag, the 3-step branch, and the unused UploadToS3 client method); the TypeScript and Python examples do one multipart request; READMEs document only the single upload.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the demo CLI, examples, and docs to use the External API’s single multipart upload endpoint (POST /documents/upload) everywhere, removing the old 3-step upload flow.

Changes:

  • Removed the CLI’s 3-step upload branch and the --single-request flag; upload now always uses multipart upload.
  • Updated the TypeScript and Python examples to upload via a single multipart request.
  • Updated documentation to describe only the single-request upload flow.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Removes 3-step upload docs; documents multipart upload as the only flow.
examples/typescript/upload-and-poll.ts Switches to multipart upload via fetch + FormData.
examples/python/sync-polling.ipynb Switches to multipart upload via httpx; removes create/S3/complete steps.
cli/README.md Updates CLI docs/examples to reflect multipart-only upload.
cli/cmd/upload.go Removes flag/branching and always uploads via UploadMultipart.
cli/api/client.go Removes the S3 helper (UploadToS3); retains multipart upload client method.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cli/cmd/upload.go
Comment thread cli/api/client.go Outdated
@specialistvlad specialistvlad added the enhancement New feature or request label Jun 2, 2026
- UploadMultipart now writes the `size` form field (exact byte count, len(data))
  before the file part. POST /documents/upload requires [name, size, file] and
  rejects a mismatched byte count, so the prior body was incomplete. Brings the
  Go CLI in line with the TypeScript + Python examples and the README.
- upload.go now errors explicitly when the upload response has no `id`, instead
  of silently polling /documents//processing/latest until timeout.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Nick-Belhovskyi Nick-Belhovskyi requested a review from a team June 2, 2026 17:36
@Nick-Belhovskyi

Nick-Belhovskyi commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

Both addressed in b5b1ad7:

  1. size is contract-required (POST /documents/uploadrequired: [name, size, file], byte-count checked), so the Go CLI body was incomplete — added size to UploadMultipart. CLI / TS / Python / README now all send it.
  2. Added an explicit error when the upload response has no id (no more silent poll-to-timeout on /documents//processing/latest).

@specialistvlad specialistvlad left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@specialistvlad specialistvlad merged commit 3b85124 into main Jun 3, 2026
3 checks passed
@specialistvlad specialistvlad deleted the single-upload-only branch June 4, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants