We should stream the Chunks for PUT requests.
This commit is contained in:
parent
3d80586e26
commit
7be4d3a0f4
1 changed files with 21 additions and 7 deletions
|
@ -63,15 +63,29 @@ async def proxy_request(path: str, request: Request):
|
||||||
return Response(content=error_xml, status_code=403, media_type="application/xml")
|
return Response(content=error_xml, status_code=403, media_type="application/xml")
|
||||||
|
|
||||||
# Proxy request to MinIO
|
# Proxy request to MinIO
|
||||||
async with httpx.AsyncClient(timeout=300.0) as client:
|
|
||||||
minio_url = f"{MINIO_ENDPOINT}/{path}"
|
minio_url = f"{MINIO_ENDPOINT}/{path}"
|
||||||
headers = dict(request.headers)
|
headers = dict(request.headers)
|
||||||
body = await request.body()
|
|
||||||
|
|
||||||
|
async with httpx.AsyncClient(timeout=300.0) as client:
|
||||||
logging.info(f"Proxying request to MinIO: {minio_url}")
|
logging.info(f"Proxying request to MinIO: {minio_url}")
|
||||||
|
if request.method in ["PUT", "POST"]:
|
||||||
|
# Stream request body to MinIO
|
||||||
|
async def request_stream():
|
||||||
|
async for chunk in request.stream():
|
||||||
|
yield chunk
|
||||||
|
|
||||||
minio_response = await client.request(
|
minio_response = await client.request(
|
||||||
method=request.method, url=minio_url, headers=headers, content=body
|
method=request.method,
|
||||||
|
url=minio_url,
|
||||||
|
headers=headers,
|
||||||
|
content=request_stream()
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# For GET and DELETE, we don’t send a body
|
||||||
|
minio_response = await client.request(
|
||||||
|
method=request.method,
|
||||||
|
url=minio_url,
|
||||||
|
headers=headers
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.info(f"MinIO response: {minio_response.status_code}")
|
logging.info(f"MinIO response: {minio_response.status_code}")
|
||||||
|
|
Loading…
Add table
Reference in a new issue