Skip to content

Audio Streaming Server with Axum #2658

Answered by adriandelgado
Tahinli asked this question in Q&A
Discussion options

You must be logged in to vote

You can use ServeFile. See: #608 (comment) Edit: not relevant to the question

Take a look at this PR: https://github.com/tokio-rs/axum/pull/3047/files#diff-85ae2acd48337869f0504aa4eced18f7129187436fedaeee5e5c941c41d6292d. Specifically at the try_stream function.
Also, take a look at how ServeDir implements sending a portion of a file https://docs.rs/tower-http/latest/src/tower_http/services/fs/serve_dir/future.rs.html#253. It seems like you want to manually send what part of the file you want. I recommend using an AtomicUsize to keep track of which part of the file you should send to everyone.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@Tahinli
Comment options

@adriandelgado
Comment options

@Tahinli
Comment options

Answer selected by Tahinli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants