Blog

Spring Boot とファイルアップロード

File upload のサンプルがこれ。 https://spring.io/guides/gs/uploading-files/

http://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/autoconfigure/web/MultipartProperties.html このへんによると、

multipart.location specifies the directory where files will be stored. The default is "". A common value is to use the system's temporary directory, which can be obtained.
multipart.maxFileSize specifies the maximum size permitted for uploaded files. The default is 1Mb.
multipart.maxRequestSize specifies the maximum size allowed for multipart/form-data requests. The default is 10Mb
multipart.fileSizeThreshold specifies the size threshold after which files will be written to disk. Default is 0, which means that the file will be written to disk immediately.

とのこと。multipart.maxFileSize が 1Mb なのは、最近のでっかい画像を考えるとちょっと足りない。

なので、通常は、ファイルをアップロードさせるアプリケーションを開発するときには、明示する必要がある。

multipart.fileSizeThreshold は、なんか大きめの値を設定したくなりがちだが、通常はデフォルトの0で問題ないと思う。小さいファイルをたくさんアップさせるようなサービスの場合は別だが、そんなサービスそうそうない。