提问人:Hamoun Karami 提问时间:11/17/2023 最后编辑:Brian Tompsett - 汤莱恩Hamoun Karami 更新时间:11/17/2023 访问量:35
OpenAPI 架构 - 将请求放入 S3 将二进制文件 (.doc/.pdf) 转换为空的 json 文件
OpenAPI Schema - Put Request into S3 turns binary file (.doc/.pdf) into empty json file
问:
我正在 chatGPT 中开发一个自定义 GPT 4 应用程序,在配置选项卡中,您可以在其中实现一些 OpenAPI 模式。
我正在尝试简单地发出 PUT 请求以将上传的文件 (.pdf) 移动到 S3 存储桶中。
我成功连接到 API,但是当我在 S3 中查看时,该文件要么是空的,要么里面有少量关于文档的信息。
即
{“metadata”: {“name”: “手册”, “description”: “Capri 的综合手册,包括重要的联系电话、其他信息、说明、建议和常见问题解答.pdf。
有人可以帮我了解我试图做的事情是否可行以及我该怎么做吗?我在 POSTMAN 中尝试了 API,响应是 200,文件是原始格式。
我试过邮递员,效果很好; 一旦我尝试将其引入 OpenAPI 模式,我就输了......
这是我的架构代码:
{
"openapi": "3.1.0",
"info": {
"title": "S3 Bucket File Management API",
"version": "1.0.0"
},
"servers": [
{
"url": "https://HIDDEN.execute-api.us-east-1.amazonaws.com/prod"
}
],
"paths": {
"/bnb-bucket-ham/{filename}": {
"put": {
"summary": "Upload a file to the S3 bucket",
"operationId": "uploadFile",
"parameters": [
{
"name": "filename",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"metadata": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
}
},
"required": ["name"]
},
"fileData": {
"type": "string",
"format": "byte"
}
},
"required": ["metadata", "fileData"]
}
},
"application/pdf": {},
"application/msword": {},
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": {}
}
},
"responses": {
"200": {
"description": "File uploaded successfully"
}
}
},
"get": {
"summary": "Retrieve a file from the S3 bucket",
"operationId": "getFile",
"parameters": [
{
"name": "filename",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "File retrieved successfully",
"content": {
"application/pdf": {
"schema": {
"type": "string",
"format": "binary"
}
},
"application/msword": {
"schema": {
"type": "string",
"format": "binary"
}
},
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
},
"404": {
"description": "File not found"
}
}
}
}
}
}
答: 暂无答案
评论