mirror of
https://github.com/timvisee/ffsend.git
synced 2025-10-03 09:39:15 +02:00
Set the encrypted file reader length
This commit is contained in:
parent
ac918cd092
commit
e54565724c
1 changed files with 9 additions and 2 deletions
11
src/main.rs
11
src/main.rs
|
@ -114,11 +114,12 @@ fn main() {
|
|||
&iv,
|
||||
);
|
||||
|
||||
// Buffer the encrypted reader
|
||||
// Buffer the encrypted reader, and determine the length
|
||||
let reader_len = reader.len().unwrap();
|
||||
let reader = BufReader::new(reader);
|
||||
|
||||
// Build the file part, configure the form to send
|
||||
let part = Part::reader(reader)
|
||||
let part = Part::reader_with_length(reader, reader_len)
|
||||
.file_name(file_name)
|
||||
.mime(APPLICATION_OCTET_STREAM);
|
||||
let form = reqwest::multipart::Form::new()
|
||||
|
@ -304,6 +305,12 @@ impl EncryptedFileReaderTagged {
|
|||
tag: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculate the total length of the encrypted file with the appended
|
||||
/// tag.
|
||||
pub fn len(&self) -> Result<u64, io::Error> {
|
||||
Ok(self.file.metadata()?.len() + TAG_LEN as u64)
|
||||
}
|
||||
}
|
||||
|
||||
impl Read for EncryptedFileReaderTagged {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue