inflearn logo
강의

講義

知識共有

Node.jsにTypeScriptを適用する(feat. NodeBird)

user, post ルーター 作成

'S3' 형식에 'S3Client' 형식의 destroy, middlewareStack, send 속성이 없습니다.ts(2739)

509

abc2752

投稿した質問数 2

0

안녕하세요 선생님

user, post 라우터 편을 보면서 코드를 작성하던중 에러가 발생해서 문의드립니다.

 

AWS S3 업로드 관련 부분인데

 

AWS.config.update({
  region: 'ap-northeast-2',
  accessKeyId: process.env.S3_ACCESS_KEY_ID,
  secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
});

const upload = multer({
  storage: multerS3({
    s3: new AWS.S3(), 
    // s3 이부분에서 에러가 발생합니다
    bucket: 'react-nodebird',
    key(req, file, cb) {
      cb(null, `original/${+new Date()}${path.basename(file.originalname)}`);
    },
  }),
  limits: { fileSize: 20 * 1024 * 1024 },
});

 

'S3' 형식에 'S3Client' 형식의 destroy, middlewareStack, send 속성이 없습니다.ts(2739)
(property) Options.s3: S3Client
빠른 수정을 사용할 수 없음

 

위와 같은 에러가 발생했습니다.

 

그래서 구글링을 통해 에러를 수정한 코드가 아래와 같은데 이 부분이 올바르게 작성된건지 확인부탁드리고자 질문남깁니다.

 

const upload = multer({
  storage: multerS3({
    s3: new S3Client({
      credentials: {
        accessKeyId: process.env.S3_ACCESS_KEY as string,
        secretAccessKey: process.env.S3_SECRET_KEY as string,
      },
      region: 'ap-northeast-2',
    }),
    bucket: 'react-nodebird',
    key(req, file, cb) {
      cb(null, `original/${+new Date()}${path.basename(file.originalname)}`);
    },
  }),
  limits: { fileSize: 20 * 1024 * 1024 },
});

 

 

node.js 웹앱 typescript

回答 1

0

zerocho

네 multer-s3와 aws-sdk의 버전 호환성 차이였을겁니다.

수정하신 것 맞습니다.

throw new Error(`${this.name}.hasMany called with something that's not a subclass of Sequelize.Model`); 에러 질문

0

343

1

안녕하세요.. connect ECONNREFUSED 127.0.0.1:3306 관련해서 질문드립니다

0

958

1

@types를 dependencies에 넣는 이유?

0

401

1

JS에서 babel 사용시 `import * as` 구문을 안써도되는데, 바벨이 esModuleInterop: true 로 처리해주는 것인가요?

0

318

1

Sequelize Association 오류

0

515

2

Sequelize constructor.primaryKeyAttributes 오류

0

973

1

Sequelize에 요청을 보내면 오류가 뜹니다

0

797

1

강좌에서 사용된 3개의 코드 의미가 궁금합니다 [ 코드 : 1. [ key:string]:string] 2. delete user.password , 3.passport.deserializeUser<number> ]

0

339

1

@mui/x-data-grid 에 사용자정의 컬럼 타입을 추가해서 사용하려고 합니다.

0

2621

1

미들웨어 에러

1

313

1

Could not find a declaration file for mould '../utils/jwt-utils'

1

181

1

마지막에 type과 interface 추가하는 부분

0

218

1

다른 컴퓨터에서 제가 만든 DB 테이블의 데이터를 그대로 사용하려면?

0

282

1

express 모듈 에러 관련

0

241

1

import * as A from 'B'

0

216

1

MySql ssl 보안 옵션 질문 입니다.

0

353

2

passport/index.ts 에러 입니다

1

453

1

routes/post.ts 페이지에서 에러나요..

0

315

1

passport/index.ts 에러납니다...

0

818

1

ts import 에러

0

443

1

타입스크립트로 변환후 nextjs 빌드 후 배포

0

263

1

sequelize include 질문드립니다.!

0

192

1

roperty 'id' does not exist on type 'User'.

0

900

1

passport user.id 질문드립니다.

0

204

1