0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SpringBootで画像データをControllerで受け取る

Posted at

結論

画像データは、MultipartFile型で受け取る

引用 :

説明

"https://spring.pleiades.io/guides/gs/uploading-files/"
を参考にされるといいです。

以下のようにMultipartFile型の引数で受け取っています。

@PostMapping("/")
	public String handleFileUpload(@RequestParam("file") MultipartFile file) {

補足

あと、
アップロードされた画像のファイル名も取得できます

        ...
		storageService.store(file);
		redirectAttributes.addFlashAttribute("message",
				"You successfully uploaded " + file.getOriginalFilename() + "!");

		return "redirect:/";
	}

この部分です。

file.getOriginalFilename()
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?