Features

Multipart Form Data

SDKs that handle multipart form data

Fern generated SDKs natively support uploading files and other media through multipart form data uploads.

The TypeScript SDK will accept either a fs.readStream, fs.ReadableStream or a Blob for the file types. This is to ensure that the file upload functionality can be used in the browser, Node.js and edge runtimes like Next.js and Cloudflare.

This is what the SDK method signature would look like:

DocumentClient.ts
1export interface DocumentClient {
2
3 /**
4 * Upload a document.
5 */
6 public async upload(
7 contents: fs.ReadStream | fs.ReadableStream | Blob,
8 request: UploadDocumentBodyRequest,
9 requestOptions?: RequestOptions
10 ): Promise<UploadDocumentResponse>
11}

and how a user would consume it

1await client.documents.upload(fs.createReadStream('/path/to/your/file.txt'), {
2 label: 'Human-friendly label for your document',
3});