feat: add App API Assets methods + multipart upload#241
Merged
Conversation
Batch 10 (stacked on Batch 9). Adds the 10 asset file/folder endpoints to APIClient, plus a multipart/form-data upload path in the request layer. Verified against the services backend (ext_api/assets/*), not the OpenAPI spec. Notable backend truths the issue's base64 assumption missed: - POST /v1/assets/files is multipart/form-data (form field 'file' + optional name/parent_folder_id), NOT base64 JSON. Added CIORequest.postForm + formOptions, which omit the JSON Content-Type so fetch sets the multipart boundary. createAsset builds a FormData from a Blob. - Asset/folder ids are integers; parent_folder_id on update is tri-state. - File DELETE returns 204; folder DELETE returns 200 (null body). - Uploads: images + PDF, <=2MB, images <=4096px/side. Includes unit tests (100% coverage, incl. the new transport path), live round-trip coverage with a real 1x1 PNG upload, and docs.
Narrow the file-upload data field from `any` to `Uint8Array | ArrayBuffer | Blob | string` — the set `new Blob([...])` actually accepts (a Node `Buffer` is a `Uint8Array`). Avoids the DOM-only `BlobPart` alias, which isn't in this project's lib.
karngyan
approved these changes
Jul 14, 2026
mike-engel
added a commit
that referenced
this pull request
Jul 14, 2026
…in formOptions (CDP-6274) Addresses PR #241 review: - createAsset without an explicit contentType would always 400: an untyped Blob part is serialized as application/octet-stream, which the Assets API rejects, and its filename fallback (mime.TypeByExtension) only runs when the part carries no Content-Type. Derive the MIME type from the filename extension client-side (bmp/jpg/jpeg/png/gif/pdf) so the part is correctly typed. Verified against ext_api/assets/create_asset.go + domains/assets. - formOptions now strips any Content-Type coming from defaults.headers, so a stray custom Content-Type can't break the multipart boundary. - Docs + tests updated; live round-trip now omits contentType to exercise the derivation end-to-end.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5b26bc7. Configure here.
…in formOptions (CDP-6274) Addresses PR #241 review: - createAsset without an explicit contentType would always 400: an untyped Blob part is serialized as application/octet-stream, which the Assets API rejects, and its filename fallback (mime.TypeByExtension) only runs when the part carries no Content-Type. Derive the MIME type from the filename extension client-side (bmp/jpg/jpeg/png/gif/pdf) so the part is correctly typed. Verified against ext_api/assets/create_asset.go + domains/assets. - formOptions now strips any Content-Type coming from defaults.headers, so a stray custom Content-Type can't break the multipart boundary. - Docs + tests updated; live round-trip now omits contentType to exercise the derivation end-to-end.
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.

Another set of the App API backfill on top of #240 which adds 10 methods plus a
multipart/form-dataupload path in the request layer.listAssetsGET /v1/assetscreateAssetPOST /v1/assets/files(multipart upload)getAssetGET /v1/assets/files/{id}updateAssetPUT /v1/assets/files/{id}(204)deleteAssetDELETE /v1/assets/files/{id}(204)listAssetFoldersGET /v1/assets/folderscreateAssetFolderPOST /v1/assets/foldersgetAssetFolderGET /v1/assets/folders/{id}updateAssetFolderPUT /v1/assets/folders/{id}(204)deleteAssetFolderDELETE /v1/assets/folders/{id}(200)The issue assumed the
SendEmailRequest.attachbase64 approach. Asset creation, however, ismultipart/form-data; form fieldfileplus optionalname/parent_folder_idform values. The JSON mode that exists there only records metadata for an already-uploaded path; it never carries bytes. So base64-in-JSON would not work.To support it, the transport gained a small, isolated multipart path:
CIORequest.postForm(uri, form)+formOptions(...)(lib/request.ts): builds the request with aFormDatabody and deliberately omits the JSONContent-Typesofetchsetsmultipart/form-datawith the correct boundary; noContent-Lengthis computed. Retries/redirects reuse the samehandler/executepath unchanged (RequestHandlerOptions.bodywidened tostring | FormData | null).createAssetbuildsFormDatafrom aBlob(setting the blob's type whencontentTypeis given, else letting the API derive it from the filename).Assisted by AI 🤖
Note
Medium Risk
Touches the shared HTTP client (
RequestHandlerOptions,execute) for FormData, but the multipart path is isolated; main risk is upload MIME handling and regressions on JSON requests.Overview
Adds Assets coverage to
APIClient: list/upload/get/update/delete files and the same CRUD for asset folders (integer ids, page-based listing with optional folder filters).createAssetpostsmultipart/form-datavia a newpostForm/formOptionspath on the shared request layer. Request bodies can beFormData; JSONContent-TypeandContent-Lengthare omitted sofetchsets the multipart boundary. The SDK derives MIME types from filename (or explicitcontentType/ Blob type) so uploads are not sent asapplication/octet-stream.Public types (
AssetListOptions,CreateAssetInput, etc.),docs/app.mdreference, unit tests, request-layer tests, and live integration round-trips are included.Reviewed by Cursor Bugbot for commit 0941010. Bugbot is set up for automated code reviews on this repo. Configure here.