[TIL] 230812 MutipartFile๊ฐ€ ๋ญ˜๊นŒ์š”

CountryGirlยท2023๋…„ 8์›” 12์ผ
0

TIL

๋ชฉ๋ก ๋ณด๊ธฐ
40/80

๐Ÿ˜Ž MutipartFile

A representation of an uploaded file received in a multipart request.
The file contents are either stored in memory or temporarily on disk.
In either case, the user is responsible for copying file contents to a session-level or persistent store as and if desired.
The temporary storage will be cleared at the end of request processing.

  • ์—…๋กœ๋“œ ํ•œ ํŒŒ์ผ์„ ํ‘œํ˜„ํ•  ๋•Œ ์‚ฌ์šฉ๋˜๋Š” interface
  • ํŒŒ์ผ ๋‚ด์šฉ์€ ๋ฉ”๋ชจ๋ฆฌ์— ์ €์žฅ๋˜๊ฑฐ๋‚˜ ๋””์Šคํฌ์— ์ผ์‹œ์ ์œผ๋กœ ์ €์žฅ ํ›„, ์š”์ฒญ ์ฒ˜๋ฆฌ๊ฐ€ ๋๋‚˜๋ฉด ์ž„์‹œ ์ €์žฅ์†Œ๊ฐ€ ์‚ญ์ œ๋œ๋‹ค.
typemethoddescription
StringgetName()ํŒŒ๋ผ๋ฏธํ„ฐ์˜ ์ด๋ฆ„
StringgetOriginalFilename()์—…๋กœ๋“œํ•˜๋Š” ์›๋ณธ ํŒŒ์ผ์˜ ์ด๋ฆ„
StringgetContentType()ํŒŒ์ผ ๋‚ด์šฉ์˜ ์œ ํ˜• (์ •์˜๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ: null)
booleanisEmpty()ํŒŒ์ผ์ด ์กด์žฌํ•˜๋Š”์ง€ ์กด์žฌํ•˜์ง€ ์•Š๋Š”์ง€
longgetSize()ํŒŒ์ผ ํฌ๊ธฐ๋ฅผ ๋ฐ”์ดํŠธ ๋‹จ์œ„๋กœ
byte[]getBytes()ํŒŒ์ผ ๋‚ด์šฉ์„ ๋ฐ”์ดํŠธ ๋ฐฐ์—ด๋กœ
InputStreamgetInputStream()ํŒŒ์ผ์˜ ๋‚ด์šฉ์„ ์ฝ์„ ์ž…๋ ฅ ์ŠคํŠธ๋ฆผ์„ ๋ฐ˜ํ™˜
ResourcegetResource()ํŒŒ์ผ์˜ ๋ฆฌ์†Œ์Šค ํ‘œํ˜„์„ ๋ฐ˜ํ™˜
voidtransferTo(File dest)์ˆ˜์‹ ๋œ ํŒŒ์ผ์„ ์ง€์ •๋œ ๋Œ€์ƒ ํŒŒ์ผ๋กœ ์ „์†ก
(๋Œ€์ƒ ํŒŒ์ผ์ด ์ด๋ฏธ ์žˆ์œผ๋ฉด ๋จผ์ € ์‚ญ์ œ
/ ํŒŒ์ผ ์‹œ์Šคํ…œ์—์„œ ์ด๋™๋˜๋ฉด ๋‹ค์‹œ ํ˜ธ์ถœํ•  ์ˆ˜ ์—†์Œ)

๐Ÿ’ก ์‚ฌ์šฉ์ž๊ฐ€ ์—…๋กœ๋“œํ•œ File์„ ํ•ธ๋“ค๋Ÿฌ์—์„œ ์†์‰ฝ๊ฒŒ ๋‹ค๋ฃฐ ์ˆ˜ ์žˆ๋„๋ก ํ•ด์ค€๋‹ค!


๐Ÿ“ File

  • Fileํด๋ž˜์Šค๋ฅผ ํ†ตํ•ด์„œ ํŒŒ์ผ๊ณผ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋‹ค๋ฃฐ ์ˆ˜ ์žˆ๋‹ค.
  • ๊ฒฝ๋กœ๋ช… ๋ฌธ์ž์—ด์€ ์‹œ์Šคํ…œ์— ๋”ฐ๋ผ์„œ ๋‹ค๋ฅด๋‹ค.
    - file.separator ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๊ตฌ๋ถ„ ๋ฌธ์ž๋ฅผ ์‚ฌ์šฉํ•˜๋„๋ก ํ•œ๋‹ค.

โœ… Reference

profile
๐Ÿ’ป๐ŸŒพ์‹œ๊ณจ์†Œ๋…€์˜ ์—‰๋ง์ง•์ฐฝ ๊ฐœ๋ฐœ ์„ฑ์žฅ์ผ์ง€๐ŸŒพ๐Ÿ’ป (2023.05.23 ~)

0๊ฐœ์˜ ๋Œ“๊ธ€