#[derive(Debug)]
#[non_exhaustive]
pub enum File<'a> {
Path(::std::path::PathBuf),
Buf{filename: ::std::borrow::Cow<'static, str>, file: reqwest::Body, length: Option<u64>, mime_type: ::std::borrow::Cow<'a, str>}
}
impl File<'_> {
pub(crate) async fn get_multipart<T>(self) -> Result<::reqwest::multipart::Part, crate::apis::Error<T>> {
match self {
File::Path(path) => Ok(reqwest::multipart::Part::file(path).await?),
File::Buf{filename, file, length, mime_type} => {
let part = if let Some(length) = length {
reqwest::multipart::Part::stream_with_length(file, length)
} else {
reqwest::multipart::Part::stream(file)
}
.file_name(filename)
.mime_str(&*mime_type)?;
Ok(part)
}
}
}
}