Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this.client.send is not a function #169

Closed
victorbianconi opened this issue May 29, 2022 · 4 comments
Closed

this.client.send is not a function #169

victorbianconi opened this issue May 29, 2022 · 4 comments

Comments

@victorbianconi
Copy link

victorbianconi commented May 29, 2022

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...

@khalidahmed1101
Copy link

Same issue happening with me,
Any solution please, thanks

@LinusU
Copy link
Collaborator

LinusU commented May 30, 2022

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

@victorbianconi
Copy link
Author

Multer S3: 3.00,
AWS SDK: 2.1145.0

@LinusU
Copy link
Collaborator

LinusU commented May 30, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants