diff --git a/server/cmd/api/api/fs.go b/server/cmd/api/api/fs.go index 33d5a9dd..4e2f8764 100644 --- a/server/cmd/api/api/fs.go +++ b/server/cmd/api/api/fs.go @@ -686,9 +686,17 @@ func (s *ApiService) UploadFiles(ctx context.Context, request oapi.UploadFilesRe } return idx, field, true } - // forms like files.0.file + // forms like files.0.file OR files.file (no index → index 0) if strings.HasPrefix(name, "files.") { parts := strings.Split(name, ".") + if len(parts) == 2 { + // comma/no-index format: files.dest_path or files.file + field := parts[1] + if field == "file" || field == "dest_path" { + return 0, field, true + } + return 0, "", false + } if len(parts) != 3 { return 0, "", false } diff --git a/server/cmd/api/api/fs_test.go b/server/cmd/api/api/fs_test.go index f8ddee44..119858b6 100644 --- a/server/cmd/api/api/fs_test.go +++ b/server/cmd/api/api/fs_test.go @@ -347,6 +347,33 @@ func TestUploadFilesMultipleAndOutOfOrder(t *testing.T) { } } +func TestUploadFilesCommaFormat(t *testing.T) { + t.Parallel() + ctx := context.Background() + svc := &ApiService{} + + tmp := t.TempDir() + dest := filepath.Join(tmp, "comma.txt") + + // SDK "comma" array format: files.dest_path, files.file (no index) + reader := buildUploadMultipart(t, + map[string]string{"files.dest_path": dest}, + map[string]string{"files.file": "hello comma"}, + ) + + resp, err := svc.UploadFiles(ctx, oapi.UploadFilesRequestObject{Body: reader}) + if err != nil { + t.Fatalf("UploadFiles error: %v", err) + } + if _, ok := resp.(oapi.UploadFiles201Response); !ok { + t.Fatalf("unexpected response type: %T", resp) + } + data, err := os.ReadFile(dest) + if err != nil || string(data) != "hello comma" { + t.Fatalf("uploaded file mismatch: %v %q", err, string(data)) + } +} + func TestUploadZipSuccess(t *testing.T) { t.Parallel() ctx := context.Background()