0

Error: Type 'S3' is missing the following properties from type 'S3Client': destroy, middlewareStack, send

My Code:

import configs from '@/configs';
import AWS from 'aws-sdk';
import multer from 'multer';
import multerS3 from 'multer-s3';

// Configure AWS SDK
AWS.config.update({
  accessKeyId: configs.S3_ACCESS_KEY,
  secretAccessKey: configs.S3_SECRET_KEY,
  region: configs.S3_REGION,
});
const spacesEndpoint = new AWS.Endpoint('nyc3.digitaloceanspaces.com');
const s3 = new AWS.S3({
  endpoint: spacesEndpoint,
});
// Create an uploader function
const uploader = multer({
  storage: multerS3({
    s3, // Getting error here
    bucket: configs.S3_BUCKET_NAME!,
    acl: 'public-read',
    contentType: multerS3.AUTO_CONTENT_TYPE,
    key(req, file, cb) {
      const uniqueId = Date.now().toString();
      cb(null, `${configs.S3_BUCKET_LOCATION}/${uniqueId}_${file.originalname}`);
    },
  }),
});

export default uploader;

Please help

Typescript error while try to upload file on s3 Type 'S3' is missing the following properties from type 'S3Client': destroy, middlewareStack, send

0 Answers0