Stream file with multipart Form. #2398
-
I am trying to stream a file to let m = zip.metadata().unwrap();
// FramedRead::new(tokio::fs::File::from_std(zip), BytesCodec::new());
// reqwest::Body::wrap_stream(FramedRead::new(tokio::fs::File::from_std(zip),
// BytesCodec::new()));
let form = Form::new()
.text("key", fields.key.clone())
.text("acl", fields.acl)
.text("policy", fields.policy)
.text("Content-Type", fields.content_type)
.text("x-amz-algorithm", fields.x_amz_algorithm)
.text("x-amz-credential", fields.x_amz_credential)
.text("x-amz-date", fields.x_amz_date)
.text("x-amz-security-token", fields.x_amz_security_token)
.text("x-amz-signature", fields.x_amz_signature)
.part(
"file",
Part::stream_with_length(
reqwest::Body::wrap_stream(FramedRead::new(
tokio::fs::File::from_std(zip),
BytesCodec::new(),
)),
m.len(),
)
.file_name(fields.key),
);
client
.post(url)
.multipart(form)
.send()
.await?
.error_for_status()?; If I If using a stream, then it complains that I wonder how properly I could move on without fully reading the file into memory and using |
Beta Was this translation helpful? Give feedback.
Answered by
silvestrpredko
Aug 20, 2024
Replies: 1 comment
-
I forgot to seek a file. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
silvestrpredko
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I forgot to seek a file.