250x250
Notice
Recent Posts
Recent Comments
Link
«   2025/10   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

devlog_owen

231124 TIL) thunderclient,restclient로 이미지 파일 업로드하기 본문

TIL

231124 TIL) thunderclient,restclient로 이미지 파일 업로드하기

developer_owen 2023. 11. 24. 20:34
728x90

뉴스피드 프로젝트 4일차

 

프론트엔드 파트를 하고 있다가 이미지 업로드가 안되서 난항을 겪고 있었다. 요즘 새로 알게된 restclient에 푹빠진 나는 그걸로 계속 업로드로 씨름을하다 결국 튜터님을 찾아가서 두가지 방식으로 업로드 하는 방법을 알게되었다. 결론은 이미지 업로드 할 때는 thunderclient가 훨씬 편하다!!


thunerclient 로 이미지 업로드

 

1. 메서드랑 url 잘 적어준다.

2. body의 form에 들어가서 필드명과 값을 잘 적어준다.

files 체크박스를 체크해주고 필드명에 이미지를 기입하고 파일선택을 눌러줘서 업로드할 파일을 선택한다.

3. 그리고 send를 누르면 된다.


restclient 로 이미지 업로드 하기

POST https://api.example.com/user/upload
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="text"

title
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="image"; filename="1.png"
Content-Type: image/png

< ./1.png
------WebKitFormBoundary7MA4YWxkTrZu0gW--

 

 

 

rest client 소개(vs code용 확장툴) — Steemit

REST Client (vs code) REST client를 사용하면 HTTP 요청을 보내고 vs code에서 직접 응답을 볼 수 있습니다. 사이트: https://marketplace.visualstudio.com/items?itemName=humao.rest-client 사용 vs code 상에서 아래와 같이 간

steemit.com

 

 

위 페이지에서 들고왔다. 일단 바운더리를 지정해줘야한다. 

위의 코드에서는 필드명이 각각 text,image에 title, 1.png를 각각 넣어서 업로드를 한다는데...

사실 좀 복잡해서 이해가 어려웠음

 


 

728x90