인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

컴퓨터공부하자's profile image
컴퓨터공부하자

asked

Spring MVC Part 2 - Backend Web Development Utilization Technology

File upload and download implemented as an example

String에서 String으로 인코딩 한다는 개념이 이해가 안 갑니다!

Written on

·

331

0

String body = StreamUtils.copyToString(inputStream, StandardCharsets.UTF_8);

이건 말이 되는 것 같은데

String uploadFileName = item.getAttachFile().getUploadFileName();

String encodedUploadFileName = UriUtils.encode(uploadFileName, StandardCharsets.UTF_8);

이건 스트링에서 스트링으로 인코딩 한다는 뜻인데 스트링에서 스트링으로 인코딩할 필요가 있는건가요? 왜냐하면 String 데이터 형식은 메모리상에 유니코드 형태로 압축되지 않은 문자 데이터가 온전히 있다는 뜻이잖아요?

MVCspring

Answer 1

2

yh님의 프로필 이미지
yh
Instructor

안녕하세요. 컴퓨터공부하자님

HTTP 헤더는 ASCII + 일부 특수문자만 이해할 수 있습니다. (ISO-8859-1 축소 호환)

encodedUploadFileName은 HTTP 헤더에 전달해야 하기 때문에 이 포멧을 따라야 합니다. 따라서 %인코딩을 해주어야 합니다.

비슷한 질문에 답을 달아두었습니다.

https://www.inflearn.com/questions/252621

감사합니다.

컴퓨터공부하자's profile image
컴퓨터공부하자

asked

Ask a question