Multer S3 (v3) type error when implementing AWS SDK (v3) - missing properties from type 'S3'

66 Views Asked by At

I'm in the process of upgrading my AWS SDK from v2 to v3 (@aws-sdk/client-s3 v3.496.0). This includes upgrading multer-s3 to v3.0.1 to be compatible as stated by their docs. But I'm getting the following type error when I'm trying to associate the instantiated s3 object within multerS3{}.

Type 'S3Client' is missing the following properties from type 'S3': abortMultipartUpload, completeMultipartUpload, copyObject, createBucket, and 106 more.ts(2740)

With some Googling I see that abortMultipartUpload is part of S3. I update the import from S3Client to S3 but then I get a different type error at the same spot.

Type 'S3' is missing the following properties from type 'S3': getBucketLifecycle, getBucketNotification, putBucketLifecycle, putBucketNotification, and 11 more.ts(2740)

import { S3 } from '@aws-sdk/client-s3';

const s3 = new S3({
  region: 'us-east-2',
  credentials: {
    accessKeyId: 'foobar',
    secretAccessKey: 'fizzbuzz',
  },
});

export const upload = multer({
  storage: multerS3({
    s3, // <-- where the type error occurs regardless of using `S3` or `S3Client`
    bucket,
    key,
  }),
});

enter image description here

I believe I should be importing S3Client and not S3 but what am I missing here?

0

There are 0 best solutions below