Download a file without using "StaticFilesEndpoint" #264
Answered
by
sunli829
JadKHaddad
asked this question in
Q&A
-
Hello. Is there a way to send a file from the poem-server to the browser without using "StaticFilesEndpoint". Say I want to respond to a post request with a file and not with text. Is it possible? This functionality would be similar to python flask "send_from_directory" |
Beta Was this translation helpful? Give feedback.
Answered by
sunli829
Apr 22, 2022
Replies: 1 comment 1 reply
-
If I understand correctly, 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)?)
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
JadKHaddad
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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