title: Spring Boot Upload Multipart 413 Request Entity Too Large
body: <p>I have such a method:</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.POST)
  @ResponseStatus(HttpStatus.CREATED)
  @ResponseBody
  @PreAuthorize("@securityService.isAllowedAccessByCurrentUser(#resource?.userId)")
  public Post createPost(@RequestPart(required = false) @Valid final MultipartFile media,
          @RequestPart(required = true) @Valid PostUploadDto resource, final UriComponentsBuilder uriBuilder,
          final HttpServletResponse response) {
      return service.create(resource, media);
  }
  </code></pre>
  
  <p>In application.properties I have this:</p>
  
  <pre><code># fileupload
  spring.servlet.multipart.max-file-size=1024MB
  spring.servlet.multipart.max-request-size=1024MB
  spring.servlet.multipart.enabled=true
  </code></pre>
  
  <p>When I try and upload a 1.2 MB file, I get 413 Request Entity Too Large</p>
  
  <p>What am I doing wrong?</p>
  
  <p>EDIT:</p>
  
  <p>Here is the React code that calls the API:</p>
  
  <pre><code>export const createNewPost = async (caption, userId, tokenData, imageURI, gameId) =&gt; {
    const resource = {
      userId,
      caption,
      hashtags: allTagsFrom(caption),
      mentions: allMentionsFrom(caption),
      gameId,
      createdOn: moment()
        .utc()
        .format('YYYY-MM-DD HH:mm:ss'),
    };
    if (imageURI) {
      const { uri, type } = imageURI;
      const data = [
        {
          name: 'resource',
          type: 'application/json',
          data: JSON.stringify(resource),
        },
        {
          name: 'media',
          type,
          filename: 'media.jpg',
          data: RNFetchBlob.wrap(uri.substring(7)),
        },
      ];
      return RNFetchBlob.fetch(
        'POST',
        `${serverUrl}/post`,
        {
          Authorization: `Bearer ${tokenData.access_token}`,
          'Content-Type': 'multipart/form-data',
          Accept: 'application/json',
        },
        data
      );
    } else {
      return RNFetchBlob.fetch(
        'POST',
        `${serverUrl}/post`,
        {
          Authorization: `Bearer ${tokenData.access_token}`,
          'Content-Type': 'multipart/form-data',
          Accept: 'application/json',
        },
        [
          {
            name: 'resource',
            type: 'application/json',
            data: JSON.stringify(resource),
          },
        ]
      );
    }
  };
  </code></pre>
  
  <p>It's interesting to note that I can succesfully make this call if the media is under a certain threshold, which is smaller than the one i set in the properties file</p>