How to send image files over http without saving them? #164
Unanswered
sumit-modak
asked this question in
Q&A
Replies: 1 comment
-
Do you need this? use axum::body::Body;
use xcap::Monitor;
pub async fn screenshot() -> impl IntoResponse {
let monitors = Monitor::all().unwrap();
let monitor = monitors.into_iter().next().unwrap();
// image file path
// capturing & saving screenshot in /tmp directory
let image = monitor.capture_image().unwrap();
let buf = image.as_raw();
let body = Body::from(buf);
Ok(([(header::CONTENT_TYPE, "image/png")], body))
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to send a image file over http using
axum
crate. Here is the code that I wrote:Beta Was this translation helpful? Give feedback.
All reactions