我正在尝试将设置为S3桶的代理。我已经使用了亚马逊指南,并成功地部署了一个API,您可以在其中指定存储桶和资源路径中的对象键--也就是说,对HTTPS://<API>/{bucket name}/{object key}的调用将得到包含相关内容的200个响应。
由于我在S3存储桶上有一些大型文件,所以我想支持字节范围的抓取。如果我直接调用S3,我可以通过GET请求上的范围标头来完成这个任务。我在API代理上也尝试过同样的方法,它似乎忽略了这个参数。我总是收到200的回应与完整的内容。
我是否可以配置API网关来传递范围请求并返回206响应?
我最初的API定义如下所示。
编辑:为了澄清-我知道预先签名的URL是管理较大文件的推荐方法。在这种情况下,这不是我可以选择的。
{
"openapi": "3.0.1",
"info": {
"title": "GenericS3Reader",
"version": "2016-10-13T23:04:43Z"
},
"servers": [
{
"url": "https://XXXXXXXXXX.execute-api.eu-west-2.amazonaws.com/{basePath}",
"variables": {
"basePath": {
"default": "/test"
}
}
}
],
"paths": {
"/{folder}": {
"get": {
"parameters": [
{
"name": "folder",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "200 response",
"headers": {
"Content-Length": {
"schema": {
"type": "string"
}
},
"Date": {
"schema": {
"type": "string"
}
},
"Content-Type": {
"schema": {
"type": "string"
}
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Empty"
}
}
}
},
"400": {
"description": "400 response",
"content": {}
},
"500": {
"description": "500 response",
"content": {}
}
}
}
},
"/{folder}/{item}": {
"get": {
"parameters": [
{
"name": "item",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "folder",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "200 response",
"headers": {
"content-type": {
"schema": {
"type": "string"
}
},
"Content-Type": {
"schema": {
"type": "string"
}
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Empty"
}
},
"audio/wav": {
"schema": {
"$ref": "#/components/schemas/Empty"
}
}
}
},
"400": {
"description": "400 response",
"content": {}
},
"500": {
"description": "500 response",
"content": {}
}
}
},
"head": {
"parameters": [
{
"name": "item",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "folder",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "200 response",
"headers": {
"Content-Length": {
"schema": {
"type": "string"
}
},
"Content-Type": {
"schema": {
"type": "string"
}
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Empty"
}
}
}
},
"400": {
"description": "400 response",
"content": {}
},
"500": {
"description": "500 response",
"content": {}
}
},
"security": [
{
"sigv4": []
}
]
}
},
"/": {
"get": {
"responses": {
"200": {
"description": "200 response",
"headers": {
"Content-Length": {
"schema": {
"type": "string"
}
},
"Timestamp": {
"schema": {
"type": "string"
}
},
"Content-Type": {
"schema": {
"type": "string"
}
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Empty"
}
}
}
},
"400": {
"description": "400 response",
"content": {}
},
"500": {
"description": "500 response",
"content": {}
}
}
}
}
},
"components": {
"schemas": {
"Empty": {
"title": "Empty Schema",
"type": "object"
}
},
"securitySchemes": {
"sigv4": {
"type": "apiKey",
"name": "Authorization",
"in": "header",
"x-amazon-apigateway-authtype": "awsSigv4"
}
}
}
}发布于 2021-11-19 09:45:17
如果仔细阅读文档,您将看到:
有效载荷大小限制为10 MB。有关配置和运行REST的API网关配额。
因为有效负载也是base64编码的,这意味着实际上,即使文件小于10 is,也会达到限制。
API网关不应该用于服务大文件。推荐的方法是使用API和创建预先签名的urls,并将用户重定向到那里。
https://stackoverflow.com/questions/70031685
复制相似问题