|
2 | 2 | #[non_exhaustive] |
3 | 3 | pub enum File<'a> { |
4 | 4 | Path(::std::path::PathBuf), |
5 | | - Buf{filename: ::std::borrow::Cow<'static, str>, file: reqwest::Body, length: Option<u64>, mime_type: ::std::borrow::Cow<'a, str>} |
| 5 | + Buf{filename: ::std::borrow::Cow<'static, str>, file: ::reqwest::Body, length: ::core::option::Option<u64>, mime_type: ::std::borrow::Cow<'a, str>} |
6 | 6 | } |
7 | 7 |
|
8 | 8 | impl File<'_> { |
9 | 9 | pub(crate) async fn get_multipart<T>(self) -> Result<::reqwest::multipart::Part, crate::apis::Error<T>> { |
10 | 10 | match self { |
11 | | - //The generator likes to generate this in 7.20.0. Why? Let's not? |
12 | | - // let file = TokioFile::open(&p_form_file).await?; |
13 | | - // let stream = FramedRead::new(file, BytesCodec::new()); |
14 | | - // let file_name = p_form_file |
15 | | - // .file_name() |
16 | | - // .map(|n| n.to_string_lossy().to_string()) |
17 | | - // .unwrap_or_default(); |
18 | | - // let file_part = |
19 | | - // reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name); |
20 | | - File::Path(path) => Ok(reqwest::multipart::Part::file(path).await?), |
21 | | - File::Buf{filename, file, length, mime_type} => { |
| 11 | + //This does not compile under ci (but does not under ci?!?)? |
| 12 | + //Self::Path(path) => Ok(reqwest::multipart::Part::file(path).await?), |
| 13 | + Self::Path(path) => { |
| 14 | + //The generator likes to generate this in 7.20.0 |
| 15 | + let file = ::tokio::fs::File::open(&path).await?; |
| 16 | + let stream = ::tokio_util::codec::FramedRead::new(file, ::tokio_util::codec::BytesCodec::new()); |
| 17 | + let file_name = path |
| 18 | + .file_name() |
| 19 | + .map(|n| n.to_string_lossy().to_string()) |
| 20 | + .unwrap_or_default(); |
| 21 | + let file_part = |
| 22 | + ::reqwest::multipart::Part::stream(::reqwest::Body::wrap_stream(stream)).file_name(file_name); |
| 23 | + |
| 24 | + Ok(file_part) |
| 25 | + } |
| 26 | + Self::Buf{filename, file, length, mime_type} => { |
22 | 27 | let part = if let Some(length) = length { |
23 | | - reqwest::multipart::Part::stream_with_length(file, length) |
| 28 | + ::reqwest::multipart::Part::stream_with_length(file, length) |
24 | 29 | } else { |
25 | | - reqwest::multipart::Part::stream(file) |
| 30 | + ::reqwest::multipart::Part::stream(file) |
26 | 31 | } |
27 | 32 | .file_name(filename) |
28 | 33 | .mime_str(&*mime_type)?; |
|
0 commit comments