Fileupload - Endpoint and OpenAI Generation for the Service

news/2024/10/19 9:43:57/
aidu_pl">

题意:文件上传 - 服务的端点和OpenAI生成

问题背景:

My Endpoint is a RestConroller with a Post-Method looking like this:

我的端点是一个带有 Post 方法的 RestController,如下所示

@PostMapping(path = "/xetra", consumes =  {MediaType.APPLICATION_JSON_VALUE,MediaType.MULTIPART_FORM_DATA_VALUE})public @ResponseBody void importXetra(@RequestParam("file") MultipartFile file) {

After OpenAI Generator i get the following signature for the endpoint:

使用 OpenAI 生成器后,我得到的端点签名如下

public importXetra(importXetraRequest?: ImportXetraRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable<any>;
public importXetra(importXetraRequest?: ImportXetraRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable<HttpResponse<any>>;
public importXetra(importXetraRequest?: ImportXetraRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable<HttpEvent<any>>;
public importXetra(importXetraRequest?: ImportXetraRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable<any> {

with

export interface ImportXetraRequest { 
file: Blob;
}

My formular looks like:        我的表单如下:

<p-fileUpload name="myfile[]" [customUpload]="true" (uploadHandler)="upload($event)">
<ng-template pTemplate="toolbar"><div class="py-1">Upload 1 Files</div>
</ng-template>
<ng-template let-file pTemplate="file"><div>Custom UI to display a file</div>
</ng-template>

my upload implementation:        我的上传实现

upload (event : {files: Blob[]}) : void {
let file  = event.files[0] as File;
let request: ImportXetraRequest = ({} as any) as ImportXetraRequest;
request.file = file;
this.importEndpoint.importXetra(request).subscribe({next : (res : void) => console.log("imported"),error: (e: ErrorEvent) => console.error("error = " + e),
});
}

I don't know how exactly i can do the call to the backend, the backend says it is not a valid request. I get a 500-error. It also seems that the payload is not set/empty.

我不确定如何正确地调用后端,后端提示请求无效。我收到一个500错误。似乎负载没有设置或为空

问题解决:

The problem was, that the endpoint didn't have the correct MediaType Consumer:

问题在于,该端点没有正确的MediaType Consumer

@PostMapping(path = "/xetra", consumes =  {MediaType.MULTIPART_FORM_DATA_VALUE,
})

solved the problem.        解决了问题


http://www.ppmy.cn/news/1521135.html

相关文章

面向Data+AI时代的数据湖创新与优化(附Iceberg案例)

面向DataAI时代的数据湖创新与优化&#xff08;附Iceberg案例&#xff09; 前言面向DataAI时代的数据湖创新与优化 前言 在当今数字化时代&#xff0c;数据和人工智能&#xff08;AI&#xff09;的融合已成为推动企业发展和创新的关键力量。数据湖作为一种重要的数据存储和处理…

驱动开发系列15 - Linux Graphics Xorg 详解

目录 一:概述 二:图形硬件概览 1. 帧缓冲区 2. 显卡的图形加速功能 三:X图形(Xorg) 1. 显示管理器(Display Manager),启动和登录 2. X服务器实例 3. X网络协议和客户端库 4. X客户端/服务器2D api 5. X客户端/服务器3D api 6. X用户空间驱动程序 7. 基于内核的图形驱…

Matlab simulink建模与仿真 第七章(表查询库)

参考视频&#xff1a;simulink1.1simulink简介_哔哩哔哩_bilibili 一、表查询库中的模块概览 二、表查询模块 使用Lookup Table表查询模块&#xff0c;需要在配置窗口中建立x-y&#xff08;自变量-因变量&#xff09;离散数据对&#xff0c;x与y的维数应相同&#xff0c;x集&a…

从预警到预防:智慧哨兵如何提前化解交通安全隐患

智慧哨兵在提前化解交通安全隐患方面发挥着重要作用&#xff0c;主要通过预警到预防的全方位、立体式手段&#xff0c;有效减少交通事故的发生。以下是从预警到预防&#xff0c;智慧哨兵如何提前化解交通安全隐患的详细阐述&#xff1a; 一、预警机制 实时监测与数据分析&…

sqlite3 db.configure方法详解:设置项与默认值

在Node.js环境中&#xff0c;sqlite3库为开发者提供了一个与SQLite数据库进行交互的简洁API。除了基本的数据库操作外&#xff0c;sqlite3还允许开发者通过db.configure方法来配置数据库的一些底层参数和行为。本文将深入解析db.configure方法&#xff0c;包括其API函数定义、所…

webpack基本使用(基础)

文章目录 概要理解 一、使用示例1.引入库2.创建config/webpack.dev.js 测试环境3.创建config/webpack.prod.js 正式环境3.创建eslintrc.js4.创建babel.config.js5.package.json 总结 概要理解 vue或者react 通常用webpack作为打包工具&#xff0c;打包成浏览器识别的html、css…

@JsonFormat失败问题处理

JsonFormat失败问题处理 在开发中经常使用到时间格式&#xff0c;如果数据库的时间是timestamp格式的&#xff0c;则返回的格式通过带有毫秒 例如2024-08-30 14:53:58.236 这样子的格式&#xff0c;通常不是我们想要的&#xff1b; 但是我们又不想再后端写更多的代码&#xff…

视觉语言模型(VLMs)知多少?

最近这几年&#xff0c;自然语言处理和计算机视觉这两大领域真是突飞猛进&#xff0c;让机器不仅能看懂文字&#xff0c;还能理解图片。这两个领域的结合&#xff0c;催生了视觉语言模型&#xff0c;也就是Vision language models (VLMs) &#xff0c;它们能同时处理视觉信息和…