I am trying to return a response of a picture from S3. In StreamingResponse.stream_response
I see, that chunks are read from the stream and sent to the socket. But on the other side, nothing comes.
import uvicorn
from fastapi import FastAPI
from fastapi.responses import StreamingResponse
from aiobotocore.session import get_session
from aioboto3 import session
app = FastAPI()
@app.get("/")
async def main():
sess = get_session()
async with sess.create_client(
's3',
endpoint_url="",
aws_secret_access_key="",
aws_access_key_id=""
) as client:
result = await client.get_object(Bucket="", Key="")
return StreamingResponse(result["Body"], media_type="image/jpeg")
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8080)```