Skip to content

Commit 977f5a8

Browse files
committed
Revert "Fix ci compile error?"
This reverts commit e615895.
1 parent e615895 commit 977f5a8

2 files changed

Lines changed: 29 additions & 43 deletions

File tree

patches/better_file_upload.rs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,27 @@
22
#[non_exhaustive]
33
pub enum File<'a> {
44
Path(::std::path::PathBuf),
5-
Buf{filename: ::std::borrow::Cow<'static, str>, file: ::reqwest::Body, length: ::core::option::Option<u64>, mime_type: ::std::borrow::Cow<'a, str>}
5+
Buf{filename: ::std::borrow::Cow<'static, str>, file: reqwest::Body, length: Option<u64>, mime_type: ::std::borrow::Cow<'a, str>}
66
}
77

88
impl File<'_> {
99
pub(crate) async fn get_multipart<T>(self) -> Result<::reqwest::multipart::Part, crate::apis::Error<T>> {
1010
match self {
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} => {
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} => {
2722
let part = if let Some(length) = length {
28-
::reqwest::multipart::Part::stream_with_length(file, length)
23+
reqwest::multipart::Part::stream_with_length(file, length)
2924
} else {
30-
::reqwest::multipart::Part::stream(file)
25+
reqwest::multipart::Part::stream(file)
3126
}
3227
.file_name(filename)
3328
.mime_str(&*mime_type)?;

src/patches/better_file_upload.rs

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ pub enum File<'a> {
44
Path(::std::path::PathBuf),
55
Buf {
66
filename: ::std::borrow::Cow<'static, str>,
7-
file: ::reqwest::Body,
8-
length: ::core::option::Option<u64>,
7+
file: reqwest::Body,
8+
length: Option<u64>,
99
mime_type: ::std::borrow::Cow<'a, str>,
1010
},
1111
}
@@ -15,35 +15,26 @@ impl File<'_> {
1515
self,
1616
) -> Result<::reqwest::multipart::Part, crate::apis::Error<T>> {
1717
match self {
18-
//This does not compile under ci (but does not under ci?!?)?
19-
//Self::Path(path) => Ok(reqwest::multipart::Part::file(path).await?),
20-
Self::Path(path) => {
21-
//The generator likes to generate this in 7.20.0
22-
let file = ::tokio::fs::File::open(&path).await?;
23-
let stream = ::tokio_util::codec::FramedRead::new(
24-
file,
25-
::tokio_util::codec::BytesCodec::new(),
26-
);
27-
let file_name = path
28-
.file_name()
29-
.map(|n| n.to_string_lossy().to_string())
30-
.unwrap_or_default();
31-
let file_part =
32-
::reqwest::multipart::Part::stream(::reqwest::Body::wrap_stream(stream))
33-
.file_name(file_name);
34-
35-
Ok(file_part)
36-
}
37-
Self::Buf {
18+
//The generator likes to generate this in 7.20.0. Why? Let's not?
19+
// let file = TokioFile::open(&p_form_file).await?;
20+
// let stream = FramedRead::new(file, BytesCodec::new());
21+
// let file_name = p_form_file
22+
// .file_name()
23+
// .map(|n| n.to_string_lossy().to_string())
24+
// .unwrap_or_default();
25+
// let file_part =
26+
// reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name);
27+
File::Path(path) => Ok(reqwest::multipart::Part::file(path).await?),
28+
File::Buf {
3829
filename,
3930
file,
4031
length,
4132
mime_type,
4233
} => {
4334
let part = if let Some(length) = length {
44-
::reqwest::multipart::Part::stream_with_length(file, length)
35+
reqwest::multipart::Part::stream_with_length(file, length)
4536
} else {
46-
::reqwest::multipart::Part::stream(file)
37+
reqwest::multipart::Part::stream(file)
4738
}
4839
.file_name(filename)
4940
.mime_str(&*mime_type)?;

0 commit comments

Comments
 (0)