question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong input type in multi-file upload

See original GitHub issue

Q&A

  • Browser: chrome, mozilla
  • Swagger-UI version: Swashbuckle.AspNetCore.SwaggerUI v4.0.1
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

        [HttpPost]
        public string UploadFiles(ICollection<IFormFile> files)
        {
            return "";
        }

Example Swagger/OpenAPI definition:

    "/api/File": {
      "post": {
        "tags": [
          "File"
        ],
        "operationId": "UploadFiles",
        "consumes": [
          "multipart/form-data"
        ],
        "produces": [
          "text/plain",
          "application/json",
          "text/json"
        ],
        "parameters": [
          {
            "name": "files",
            "in": "formData",
            "required": false,
            "type": "array",
            "items": {
            },
            "collectionFormat": "multi",
            "uniqueItems": false
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "schema": {
              "type": "string"
            }
          }
        }
      }
    },

Swagger-UI configuration options:

From Swashbuckle.AspNetCore.SwaggerUI

app.UseSwaggerUI(c => c.SwaggerEndpoint($"/swagger/{SwaggerDocumentVersion}/swagger.json", $"{SwaggerDocumentVersion} docs"));

Describe the bug you’re encountering

Input type is text rather than file when a method receives muliple files (either IEnumerable<IFormFile> or IFormFileCollection) as argument.

Current behavior

real

Expected behavior

expected

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
webroncommented, Oct 18, 2019

@eduherminio - that’s OpenAPI (Swagger) 2.0, not OpenAPI 3.0. The 2.0 version does not support multi file uploads.

0reactions
eduherminiocommented, Oct 21, 2019

Oops, totally right @webron, I’ll close this and create a new one if I experience issues once I configure the project to use 3.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple file upload -- works fine when all documents are ...
The problem appears to be that when you have a blank file input, it returns an 'error' value of 4 which means UPLOAD_ERR_NO_FILE...
Read more >
Error Messages Explained - Manual - PHP
It checks the existance of a form field names "max_file_size" (upper case is also OK), which should contain an integer with the maximum...
Read more >
File Uploads - Laravel Livewire
Livewire makes uploading and storing files extremely easy. First, add the WithFileUploads trait to your component. Now you can use wire:model on file...
Read more >
[Drag and Drop Multiple File Upload - Contact Form 7] Support
Newst WordPress Version: Invalid Link on multifile images upload ... How can I change text in Drag and Drop Uploading area in specifc...
Read more >
Text Inputs - Materialize
You can also use the multiple attribute to allow multiple file uploads. File. <form action= ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found