swagger-api / swagger-api/swagger-codegen

Spring-MVC: Solution to upload a file.

Open
#1,282 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature Server: Java
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Hi,

I finally found the solution of issue #1273..

You need to had this dependency in the pom.xml file:

<dependency>
   <groupId>commons-fileupload</groupId>
   <artifactId>commons-fileupload</artifactId>
   <version>1.3.1</version> <!--Latest version-->
</dependency>

And in SwaggerConfig.java, you need to had this Bean:

@Bean
public CommonsMultipartResolver multipartResolver(){
    CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
    multipartResolver.setDefaultEncoding("UTF-8");
    multipartResolver.setMaxUploadSize(-1);
    return multipartResolver;
}

Don't forget to add:

import org.springframework.context.annotation.Bean;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

Can you make a PR request?? Thanks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the relevant Spring MVC module, its pom.xml, and SwaggerConfig.java, then read issue #1273 for the original upload failure. Compare the proposed Commons FileUpload dependency and multipart resolver configuration with the generated project structure; done means the affected Spring MVC file-upload case is supported and the relevant checks pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.