AzureExtensions.Swashbuckle icon indicating copy to clipboard operation
AzureExtensions.Swashbuckle copied to clipboard

multipart/form-data

Open imrandyk opened this issue 2 years ago • 2 comments

If there is a way to support multipart/form-data I'm not seeing? If it is supported how would you accomplish this? If not is there a plan or path to do this?

There is a need to send files as part of the form also.

imrandyk avatar Mar 09 '22 22:03 imrandyk

I try to configure to multipart/form-data but I don't, Is there way to configure ?

Guilherme-Foppa avatar Jul 09 '22 22:07 Guilherme-Foppa

Any news about this problem?

angelolsantos avatar Mar 13 '23 16:03 angelolsantos

This is an example of working with multipart data when uploading file, if it's not suffice and issue is still relevant please reopen and add new description. Thanks

image

For binary file upload

        [ProducesResponseType(typeof(TestModel), (int)HttpStatusCode.Created)]
        [RequestHttpHeader("x-ms-session-id", true)]
        [Function("TestUpload")]
        [SwaggerUploadFile("Pdf", "Pdf upload")]
        public async Task<IActionResult> TestUpload(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "test/upload")] HttpRequest req)
        {
            var data = await req.ReadFormAsync();

            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();
        }

vitalybibikov avatar May 02 '24 11:05 vitalybibikov