pub struct PreparedFileUpload {
pub kind: MediaQuality,
pub aes_key: Vec<u8>,
pub file_key: String,
pub plaintext_bytes: u32,
pub md5: String,
pub sha256: String,
pub file_name: String,
pub destination: String,
/* private fields */
}Expand description
One object ready to upload from a private file. The file is read in steps
while the object is sent; its length, MD5 and SHA-256 are checked again on
the way, and the request that ends the object is only made once every byte
read matched. Persist the key and file key before the first request, as
for PreparedUpload.
Fields§
§kind: MediaQualityCDN object type to upload as.
aes_key: Vec<u8>AES-128 key the object is encrypted with.
file_key: StringClient file key that correlates the upload’s requests.
plaintext_bytes: u32Size of the plaintext in bytes.
md5: StringLowercase hex MD5 of the plaintext.
sha256: StringLowercase hex SHA-256 of the plaintext.
file_name: StringFile name sent with the upload.
destination: StringChat the upload is for.
Implementations§
Source§impl PreparedFileUpload
impl PreparedFileUpload
Sourcepub fn new(
file: File,
length: u64,
md5: &str,
sha256: &str,
kind: MediaQuality,
file_name: &str,
destination: &str,
key: &[u8],
file_key: &str,
) -> Result<Self>
pub fn new( file: File, length: u64, md5: &str, sha256: &str, kind: MediaQuality, file_name: &str, destination: &str, key: &[u8], file_key: &str, ) -> Result<Self>
Prepare an upload of file. length, md5 and sha256 describe the
file; the caller computed them while writing it. A file of another
length is refused now, and changed bytes before the final request.
Sourcepub fn encrypted_len(&self) -> usize
pub fn encrypted_len(&self) -> usize
Length of the encrypted object, including its padding block.
Sourcepub fn to_memory(&self) -> Result<PreparedUpload>
pub fn to_memory(&self) -> Result<PreparedUpload>
The same upload held in memory, for transports that send one object per request. The file is read whole and checked against its digests.