Created
April 5, 2020 07:09
-
-
Save DmitrySoshnikov/2027a83bab8f00196d2ec295db1a40a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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