anacronw/multer-s3

this.client.send is not a function

Closed this issue · 4 comments

I've been trying to get around this error for a while but it keeps popping up, and S3 keeps billing me the requests even if no files are being uploaded.

This is my code:

require("dotenv").config();
const uniqid = require("uniqid");
const bucketName = process.env.AWS_POSTS_BUCKET_NAME;
const region = process.env.AWS_POSTS_BUCKET_REGION;
const accessKeyId = process.env.AWS_S3_UPLOADS_ACCESS_KEY;
const secretAccessKey = process.env.AWS_S3_UPLOADS_SECRET_KEY;

const aws = require("aws-sdk");
const multer = require("multer");
const multerS3 = require("multer-s3");

const s3 = new aws.S3({
  region,
  accessKeyId,
  secretAccessKey,
});

const path = uniqid();

exports.upload = multer({
  storage: multerS3({
    s3,
    bucket: bucketName,
    metadata: function (req, file, cb) {
      cb(null, { fieldName: path });
    },
    key: function (req, file, cb) {
      cb(null, path + "." + file.originalname.split(".")[1]);
    },
  }),
});

If I log the file it's being logged, but I get this.client.send is not a function every time and I don't see any new files on the bucket, but I realized I'm still being billed for the requests...

Same issue happening with me,
Any solution please, thanks

Which version of Multer S3 are you using? and which version of the AWS SDK?

Multer S3: 3.00,
AWS SDK: 2.1145.0

Multer S3 2.x is compatible with AWS SDK 2.x, and
Multer S3 3.x is compatible with AWS SDK 3.x.

Either upgrade AWS SDK, or downgrade Multer S3.