swagger-api / swagger-api/swagger-codegen
Spring-MVC: Solution to upload a file.
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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