Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ugovaretto/0c2735f5e53073752df42fe2c8bb495f to your computer and use it in GitHub Desktop.
Save ugovaretto/0c2735f5e53073752df42fe2c8bb495f to your computer and use it in GitHub Desktop.
let offset = 20000;
let chunk_size = 10000;
// File handle:
let mut handle = BufReader::new(File::open("data.bin").await?);
// Set cursor to needed chunk:
let mut chunk_stream = handle
.bytes()
.skip(offset)
.take(chunk_size);
// Error: the trait `std::convert::From<u8>` is not implemented for `bytes::bytes::Bytes`
// See: https://github.com/seanmonstar/reqwest/blob/master/src/async_impl/body.rs#L90
let chunk = multipart::Part::stream(Body::wrap_stream(chunk_stream));
// ^^^^^^^^^^^^^^^
let form = multipart::Form::new()
.text("session_id", "<session-id>")
.part("chunk", chunk);
reqwest::Client::new()
.post("<endpoint>"))
.multipart(form)
.send()
.await?;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment