How to download a file in Warp that is dynamically generated from the path?

I saw that someone asked a while back on stackoverflow (rust - Is there a way to pass a custom file path to warp::fs::file? - Stack Overflow) whether something like this is possible in warp:

        warp::path!("files" / u32)
            .map(|fileId| {
                format!("{}.txt", *FILES_PATH, fileId)
            })
            .and(warp::fs::file)

The documentation only gives an example of how to provide static files (in directories) for download (https://github.com/seanmonstar/warp/blob/master/examples/file.rs). I was wondering whether the exampl I provided (or something similar) is now possible.
Thanks!

I believe you just need to construct a http::Response<Vec>

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.