Skip to content

Commit

Permalink
Support async file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-herlemont committed Dec 5, 2024
1 parent cf78f10 commit b117d6d
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 11 deletions.
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"); },
}
{{/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

0 comments on commit b117d6d

Please sign in to comment.