[AWS] lambda 설정하기

Yun Hyuk Ko·2022년 12월 19일

AWS

목록 보기
9/9

함수 생성하기 클릭


https://kyh-my-bucket.s3.ap-northeast-2.amazonaws.com/lambda.zip


  1. 구성 > 일반구성 > 편집

  2. 트리거 추가


이후 코드를 수정 해준다.

router.post('/api/posts', (req, res) => {
  	  // 기존 주소와 리사이징된 주소를 보내주는 이유는 다음과 같다.
      // 이미지가 크거나 많으면 오래걸린다. 이미지 리사이징 시간이 조금 오래 걸릴 시
      // thumb 폴더에 결과물이 생기지 않은 경우 대비
      // 이를 방지하고자 임시 방편으로 기존 original 폴더 안에 이미지 원본을 보내준다.
      const originalFile = req.file.location;
      const resizingUrl = originalFile.replace(/\/original\//, '/thumb/');
      const user = res.locals.user;
  
      return res.status(200).json({
        resizingUrl: resizingUrl,
        originalFile: originalFile
      })
})
profile
기억보다 좋은건 기록이다

0개의 댓글