1

I have a NodeJS/Express webapp running on AWS Elastic Beanstalk and I want to allow my users to upload profile pictures to AWS S3. I want the client to directly upload to S3 because I’m planning to implement bigger file uploads later. I’m fairly new to NodeJS and AWS, how can I achieve what I’m looking for?

azure
  • 13
  • 3
  • 1
    You can use a [pre-signed URL](https://docs.aws.amazon.com/AmazonS3/latest/userguide/PresignedUrlUploadObject.html) to upload the file directly to the S3 bucket. – Arun Kumar Mohan Apr 03 '21 at 23:33

1 Answers1

0

It is not a good practice to upload to s3 from client side. If you want to upload to s3, you need to specify the AWS accessKeyId and secretAccessKey. If you do that on the client side, everybody can see that.

Check this: Amazon S3 direct file upload from client browser - private key disclosure

If you choose to go with Express, you can use the multer and multer-s3 packages with aws-sdk package.

NeNaD
  • 18,172
  • 8
  • 47
  • 89
  • 1
    Well, you can upload the file from the client-side directly to the S3 bucket by generating a short-lived [pre-signed URL](https://docs.aws.amazon.com/AmazonS3/latest/userguide/PresignedUrlUploadObject.html). This way, you don't have to upload the file twice. – Arun Kumar Mohan Apr 03 '21 at 23:30