Skip to content

Commit

Permalink
Example for #96
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalybibikov committed May 2, 2024
1 parent 5c38cc7 commit 552a91a
Showing 1 changed file with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,21 @@ public async Task<IActionResult> RequestBodyTypePresented(
[ProducesResponseType(typeof(TestModel), (int)HttpStatusCode.Created)]
[RequestHttpHeader("x-ms-session-id", true)]
[Function("TestUpload")]
[RequestHttpHeader("x-ms-session-id", true)]
[SwaggerUploadFileAttribute("Pdf", "Pdf upload")]
[SwaggerUploadFile("Pdf", "Pdf upload")]
public async Task<IActionResult> TestUpload(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "test/upload")]
HttpRequestMessage httpRequest)

[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "test/upload")] HttpRequest req)
{
//var data = await httpRequest.Content.ReadAsMultipartAsync();
var data = await req.ReadFormAsync();

//if (data != null && data.Contents != null)
//{
// foreach (var content in data.Contents)
// {
// var result = await content.ReadAsStringAsync();
// return new OkObjectResult(result.Length);
// }
//}
if (data != null)
{
foreach (var formFile in data.Files)
{
using var reader = new StreamReader(formFile.OpenReadStream());
var fileContent = await reader.ReadToEndAsync();
return new OkObjectResult(fileContent.Length);
}
}

return new NoContentResult();
}
Expand Down

0 comments on commit 552a91a

Please sign in to comment.