Skip to content

Download a file without using "StaticFilesEndpoint" #264

Answered by sunli829
JadKHaddad asked this question in Q&A
Discussion options

You must be logged in to vote

If I understand correctly, send_from_directory is used to send a single file?

Well, what you want should be this:

https://docs.rs/poem/1.3.29/poem/web/struct.StaticFileRequest.html

#[handler]
async fn index(req: StaticFileRequest) -> Result<impl IntoResponse> {
     Ok(req.create_response("/path/to/file", true)?)
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@JadKHaddad
Comment options

Answer selected by JadKHaddad
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