You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The OpenAPI generator supports APIs that use multipart (`multipart/form-data`) for file uploads and mixed content types.
158
+
The SAP Cloud SDK automatically encodes your request body as multipart form-data based on the content types specified in your OpenAPI document:
159
+
160
+
```ts
161
+
const response =awaitMyApi.uploadDocument({
162
+
title: 'My Document', // text/plain
163
+
file: newBlob([]), // application/octet-stream
164
+
metadata: { pages: 10 } // application/json
165
+
}).execute(destination);
166
+
```
167
+
168
+
#### File Uploads with Blob or File
169
+
170
+
For binary content like files or images, provide `Blob` or `File` instances.
171
+
Use `File` instead of `Blob` when you need to specify a filename, which may be required by the API.
172
+
173
+
```ts
174
+
import { openAsBlob } from'node:fs';
175
+
176
+
const pdf =awaitopenAsBlob('path/to/file.pdf', { type: 'application/pdf' });
177
+
const response =awaitMyApi.uploadDocument({
178
+
file: pdf,
179
+
description: 'My PDF file'
180
+
}).execute(destination);
181
+
```
182
+
183
+
Using `Blob` or `File` instances bypasses automatic property encoding for that field and preserves the binary data.
184
+
The SAP Cloud SDK makes a best-effort attempt to warn about content type-mismatches and apply character encoding (e.g. `utf-8`, `latin1`) based on your OpenAPI specification.
185
+
186
+
#### Full Control with FormData
187
+
188
+
For complete control over the multipart request, provide a `FormData` instance directly.
0 commit comments