Questions tagged [streamingresponsebody]
19 questions
2
votes
2 answers
Return File/Streaming response from online video URL in FastAPI
I am using FastAPI to return a video response from googlevideo.com. This is the code I am using:
@app.get(params.api_video_route)
async def get_api_video(url=None):
def iter():
req = urllib.request.Request(url)
with…

hassaan farooq
- 95
- 2
- 6
1
vote
0 answers
In FastAPI, how do you return a StreamingResponse, but also do something after the streaming is done?
In my FastAPI route, I need to return a StreamingResponse to the user as each chunk of a text sentence gets generated.
However, the complete text sentence needs to be inserted into a database. Is there a way to do this?
@app.post("/foo_stream")
def…

gameveloster
- 901
- 1
- 6
- 18
1
vote
0 answers
StreamingResponse of real time output of commands
I am developing an api that requests a command using FastAPI and receives the output for that command in real time.
There is a problem, StreamingResponse seems to be working, but the output is returned once the command is finished, not every time…

brinst
- 11
- 1
1
vote
0 answers
FastAPI's StreamingResponse doesn't return stream
Trying FastAPI's StreamingResponse, however getting TypeError: stream.on is not a function in the browser:
const response = await axios.get("http://localhost:8000/stream", {
responseType: "stream",
});
const stream =…

anthnyprschka
- 301
- 3
- 14
1
vote
2 answers
Is It possible to change the content of the Body of a responseEntity
I am trying to return the content of a Json file. But I want to modify before sending it to the front end. I want to add "[" and "]" at the beginning and end of the file. I am doing that because the json file has multiple json root elements.
Like…

Hani Gotc
- 840
- 11
- 24
1
vote
0 answers
Using StreamingResponseBody, certain very large response fails with org.apache.coyote.CloseNowException
I am creating a REST-Api with spring boot, that needs to transfer enormous JSON-Data to a client. To avoid extreme memory usage or too great array instantiations, I am using StreamingResponseBody to send the data in chunks:
@Controller
class…

JMzB
- 11
- 2
1
vote
1 answer
stream video file mp4 with Spring Boot 2 Controller StreamingResponseBody
I'm trying to stream a video file mp4 with Spring Boot 2 , I followed some tutorial and the solution should be simple... like the controller I copied below... but don't work for me.
I cant understand why..
When I put the url in my browser, the…

Paolo Biavati
- 609
- 10
- 19
0
votes
1 answer
AccessDeniedException when accessing REST API that returns StreamingResponseBody in Spring Boot 3 and latest Spring Security?
I have created this api for streaming an mp3 audio file as response.
@GetMapping (value = "/api/user/stream/{songId}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public ResponseEntity playSong(@PathVariable Long…

Kalpadiptya Roy
- 95
- 1
- 11
0
votes
0 answers
Is there a way to use FastAPI StreamingResponse with bytes like object?
In FastApi the below code is used to stream large files
def iterfile(file_name): #
with open(file_name, mode="rb") as file_like: #
yield from file_like #
return StreamingResponse(iterfile(file_),…

Sanket Wagh
- 156
- 1
- 14
0
votes
0 answers
Handling streaming response has inconsitent result across pages and browsers
I'm having issues handling StreamingResponse from FastAPI, specifically, i need to append every response from StreamingResponse into a modal (or any other HTML element) body.
However, for whatever reason - result is inconsitent.
I have an endpoint…

Marko Todoric
- 113
- 5
0
votes
0 answers
StreamingResponseBody body not executing body returning immeditly - but Rest API still in the process of downloading
I have the below code - after executing below code the client getting immediate response with blank zip file (with out having list of files) , however the StreamingResponseBody
Still executing by reading file by file and writing into output stream -…

Dayananda
- 17
- 9
0
votes
0 answers
Generating HTTP REST API endpoint from existing grpc .proto file with streaming
I have an existing java grpc server file that is generated from a .proto file. I need to add HTTP REST API endpoints for each of the rpc calls in my .proto file. Probably using google.api.http.
The .proto file looks something like:
rpc…

cmg811
- 1
0
votes
0 answers
How to fail StreamingResponseBody if an exception occurred (Spring)
I have a Spring REST endpoint that downloads a zip archive using StreamingResponseBody:
@GetMapping("/zip/download")
public ResponseEntity downloadZip(
@RequestParam String id) {
return…

vmelik
- 1
0
votes
1 answer
java.io.StreamCorruptedException: invalid stream header: C2ACC3Ad
I was trying to transmit objects between two controllers with StreamingResponseBody. All was pretty much good to me until I noticed that I transferring just a regular String. Its bytes are different from that ones I am sending from /send…

Amadis
- 11
- 2
0
votes
0 answers
Not able to set content length for ResponseEntity
I'm trying to download a zip file in spring boot. Using HttpServletResponse output stream. We will be reading a file from local, zip it, inside StreamingResponseBody and add it in the return statement of ResponseEntity.body(StreamingResponseBody).…