



일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 파이콘
- github markdown
- Machine Learning
- Morphological analysis #Corpus
- github
- 자바파이썬
- taskkill
- expression statement is not assignment or call html
- PID
- 클라이언트사이드렌더링
- 모바일웹스킨
- 마크다운
- 카우치코딩 #couchcoding #6주포트폴리오 #6주협업프로젝트v
- gitbash
- 파이썬
- Anaconda
- khaiii
- #스파르타코딩클럽후기 #내일배움캠프후기
- 플젝후체크
- SSR
- 코딩온라인
- Kakao
- terminate
- 출처: 자바의 신 8장
- 서버사이드렌더링
- 필사
- 카우치코딩 #couchcoding #6주포트폴리오 #6주협업프로젝트
- address
- Technical Writing
- 비동기
- Today
- Total
개발 일기
[프로젝트] Postman 으로 데이터 테스트하기 본문
Postman error while uploading files through form-data body type
Couldn't upload file Make sure that Postman can read files inside the working directory.
stackoverflow.com
settings 에서 허용을 해줘도 계속 can't download 에러가 뜬다. 알고보니, postman Agent 로 c 드라이브 user 에는 설정이 되어 있는데, 여기 설정은 Postman 으로 default set 이 되어있어서 포스트맨이 읽어오지 못하는 것. Agent 를 떼주면 바로 해결된다.
Postman 으로 api/post 기능 테스트하기.
UserDetails가 null이 뜨는 에러가 있었다. 401이 아닌 500에러가 떴다.
처음에는 user 객체에 필수 값인 userId 가 안들어가서 그랬나? 싶어서 넣어줘도 해결 되지 않았다.
(우리는 스프링 시큐리티를 쓰고 있고, token 값을 보내주면 로그인이 되기 때문에 userId 는 따로 써줄 필요가 없다. )
나머지 파일은 다 잘들어가는 데 User user 가 null 이기 때문에, f8 을 눌러도 넘어가지 않는다.
User user = userRepository.findByUsername(userDetails.getUsername()).orElseThrow(() -> new NullPointerException("그런 사람 없는데요?"));
// FoodImg (파일) foodImgUrl(스트링) 구분
String foodImgUrl = awsService.uploadFoodImg(postDto.getFoodImg());
// url과 함께 food 저장.
Food food = new Food(postDto, foodImgUrl);
foodRepository.save(food);
// tag - emotion 저장
List<Tag> tags1 = postDto.getPostingEmo().stream().map((tag) -> new Tag(food, tag, "emotion")).collect(Collectors.toList());
tagRepository.saveAll(tags1);
// tag - category 저장
List<Tag> tags2 = postDto.getPostingCat().stream().map((tag) -> new Tag(food, tag, "category")).collect(Collectors.toList());
tagRepository.saveAll(tags2);
// 음식명 중복 체크
Food food2 = foodRepository.findByName(postDto.getPostingFoodName()).get();
Posting posting = new Posting(postDto, user, food2);
postingRepository.save(posting);
return foodImgUrl;
아래 500에러가 계속 있었는데, User user 에서 멈춰서 null pointer exception 이 나왔다
토큰 앞부분이 똑같이 시작해서 토큰이 만료되지 않았다고 생각했는데, 혹시나 해서 전체 토큰을 비교해보니 달랐다.
그래서 토큰을 새 것으로 넣어주었더니, db에 잘 저장되었다.
토큰이 계속 만료된다는 걸 잊어서 마주한 에러다
보니 토큰이 만료된 상태이면 500에러가 뜨고, 엉뚱한 토큰을 넣으면 401이 뜨는 것 같다. (테스트해볼때마다 미묘하게 달라서 조금 더 테스트를 해봐야할 것 같다.
저장 성공 !