Send a global file input to the endpoint that accepts files

The upload went to /globals/{key}, which takes JSON, and came back as an
unsupported content type; the array variant additionally named its parts
after the input, which nothing binds on. Both now use the multipart routes
that exist for this, with the part names those routes read.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lucio Lelii 2026-09-14 12:31:43 +02:00
parent 84f528203c
commit 3af6f14bb7
1 changed files with 7 additions and 4 deletions

View File

@ -284,7 +284,9 @@ export class TaskExecutionsCallService extends TaskExecutionsCallServiceBase {
inputName: string,
file: File
): Observable<TaskExecution> {
const url = `${environment.apiUrl}/executions/${encodeURIComponent(executionId)}/globals/${encodeURIComponent(inputName)}`;
// The bare /globals/{key} endpoint takes JSON, so an upload sent there came back as an
// unsupported content type; the upload has its own route, as it does for a node input.
const url = `${environment.apiUrl}/executions/${encodeURIComponent(executionId)}/globals/${encodeURIComponent(inputName)}/file`;
const formData = new FormData();
formData.append('file', file);
return this.http.put<unknown>(url, formData).pipe(map((raw) => this.mapExecution(raw)));
@ -295,11 +297,12 @@ export class TaskExecutionsCallService extends TaskExecutionsCallServiceBase {
inputName: string,
files: File[]
): Observable<TaskExecution> {
const url = `${environment.apiUrl}/executions/${encodeURIComponent(executionId)}/globals`;
const url = `${environment.apiUrl}/executions/${encodeURIComponent(executionId)}/globals/${encodeURIComponent(inputName)}/files`;
const formData = new FormData();
formData.append('key', inputName);
// Every file goes under "files": the part name is what the endpoint binds on, and naming the
// parts after the input meant nothing bound at all.
for (const file of files) {
formData.append(inputName, file);
formData.append('files', file);
}
return this.http.put<unknown>(url, formData).pipe(map((raw) => this.mapExecution(raw)));
}