Closed frederikhors closed 1 year ago
Hi! Just see your question. I had almost the same problem. Solved it this way: link to my project
I created a GetObject command by hand, got a response and just redirected stream to my response body.
let key = self.get_s3_key(file_info);
let command = Command::GetObject;
let s3_request = Reqwest::new(&self.bucket, &key, command);
let s3_response = s3_request.response().await?;
let mut response = HttpResponseBuilder::new(actix_web::http::StatusCode::OK);
Ok(response.streaming(s3_response.bytes_stream()))
s3_response.bytes_stream()
returns Stream<Item=Result<Bytes, Err>>
which fits to actix's response.streaming
, I guess axum has almost the same signature.
Hope it helps.
Thanks. I think I'll close this because I'm not using rust-s3 anymore. Thanks again!
I'm trying to write a small axum router that uploads and downloads files.
I would like to stream those files directly to the cloud, but I don't know what to use for streaming.
In Go (my primarily language) I'm using
http.ResponseWriter
withio.Copy
.But in Rust I'm having real difficulties to understand what to use, this is the code:
[dependencies] axum = { version = "0.5.17", features = ["multipart"] } futures = "0.3.25" tokio = { version = "1.21.2", features = ["full"] } tokio-util = { version = "0.7.4", features = ["io"] } rust-s3 = "0.32.3"
QUESTIONS
The
upload
function works but I don't know what these lines mean:The
download
function doesn't work because I don't know what to use, how to create thewriter
thatget_object_stream()
needs.I can PR examples and docs, as soon as I figure out how to do it, with your help.
Thanks!