Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rust] Support async file upload #20242

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ reqwest-middleware = { version = "^0.3", features = ["json", "blocking", "multip
{{/supportMiddleware}}
{{/supportAsync}}
{{#supportAsync}}
reqwest = { version = "^0.12", features = ["json", "multipart"] }
reqwest = { version = "^0.12", features = ["json", "stream", "multipart"] }
{{#supportMiddleware}}
reqwest-middleware = { version = "^0.3", features = ["json", "multipart"] }
{{/supportMiddleware}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,22 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{/required}}
{{/supportAsync}}
{{#supportAsync}}
// TODO: support file upload for '{{{baseName}}}' parameter
{{#required}}
{{^isNullable}}
local_var_form = local_var_form.file("{{{baseName}}}", {{{paramName}}}).await?;
{{/isNullable}}
{{#isNullable}}
match {{{paramName}}} {
Some(local_var_param_value) => { local_var_form = local_var_form.file("{{{baseName}}}", local_var_param_value).await?; },
None => { unimplemented!("Required nullable form file param not supported"); },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we detect this at build-time?

}
{{/isNullable}}
{{/required}}
{{^required}}
if let Some(local_var_param_value) = {{{paramName}}} {
local_var_form = local_var_form.file("{{{baseName}}}", local_var_param_value).await?;
}
{{/required}}
{{/supportAsync}}
{{/isFile}}
{{^isFile}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
reqwest = { version = "^0.12", features = ["json", "multipart"] }
reqwest = { version = "^0.12", features = ["json", "stream", "multipart"] }
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
reqwest = { version = "^0.12", features = ["json", "multipart"] }
reqwest = { version = "^0.12", features = ["json", "stream", "multipart"] }
reqwest-middleware = { version = "^0.3", features = ["json", "multipart"] }
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,9 @@ pub async fn upload_file(configuration: &configuration::Configuration, params: U
if let Some(local_var_param_value) = additional_metadata {
local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string());
}
// TODO: support file upload for 'file' parameter
if let Some(local_var_param_value) = file {
local_var_form = local_var_form.file("file", local_var_param_value).await?;
}
local_var_req_builder = local_var_req_builder.multipart(local_var_form);

let local_var_req = local_var_req_builder.build()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
reqwest = { version = "^0.12", features = ["json", "multipart"] }
reqwest = { version = "^0.12", features = ["json", "stream", "multipart"] }
async-trait = "^0.1"
# TODO: propose to Yoshidan to externalize this as non google related crate, so that it can easily be extended for other cloud providers.
google-cloud-token = "^0.1"
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,9 @@ pub async fn upload_file(configuration: &configuration::Configuration, params: U
if let Some(local_var_param_value) = additional_metadata {
local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string());
}
// TODO: support file upload for 'file' parameter
if let Some(local_var_param_value) = file {
local_var_form = local_var_form.file("file", local_var_param_value).await?;
}
local_var_req_builder = local_var_req_builder.multipart(local_var_form);

let local_var_req = local_var_req_builder.build()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
reqwest = { version = "^0.12", features = ["json", "multipart"] }
reqwest = { version = "^0.12", features = ["json", "stream", "multipart"] }
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,9 @@ pub async fn upload_file(configuration: &configuration::Configuration, params: U
if let Some(local_var_param_value) = additional_metadata {
local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string());
}
// TODO: support file upload for 'file' parameter
if let Some(local_var_param_value) = file {
local_var_form = local_var_form.file("file", local_var_param_value).await?;
}
local_var_req_builder = local_var_req_builder.multipart(local_var_form);

let local_var_req = local_var_req_builder.build()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
reqwest = { version = "^0.12", features = ["json", "multipart"] }
reqwest = { version = "^0.12", features = ["json", "stream", "multipart"] }
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,9 @@ pub async fn upload_file(configuration: &configuration::Configuration, params: U
if let Some(local_var_param_value) = additional_metadata {
local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string());
}
// TODO: support file upload for 'file' parameter
if let Some(local_var_param_value) = file {
local_var_form = local_var_form.file("file", local_var_param_value).await?;
}
local_var_req_builder = local_var_req_builder.multipart(local_var_form);

let local_var_req = local_var_req_builder.build()?;
Expand Down
Loading