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

multipart/form-data #96

Closed
imrandyk opened this issue Mar 9, 2022 · 3 comments
Closed

multipart/form-data #96

imrandyk opened this issue Mar 9, 2022 · 3 comments

Comments

@imrandyk
Copy link

imrandyk commented Mar 9, 2022

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.

@Guilherme-Foppa
Copy link

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

@angelolsantos
Copy link

Any news about this problem?

@vitalybibikov
Copy link
Owner

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 added a commit that referenced this issue May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants