2

I'm using the Multer library to upload an image. So, I use ReactJS to upload the file to the NodeJS server. In the NodeJS server, I received a piece of image information sent from the client as this picture.

enter image description here

In the s3 upload function, I use the buffer value in this picture as a body. I uploaded it to s3 successfully but when I open the image URL, it shows me like this picture.

enter image description here

There's any suggestion or correct way to upload an image to S3.

stevenH
  • 155
  • 3
  • 13
  • 1
    This happens because there is something incorrect with the encoding, or multer doesn't accept 7bit format or the buffer it's not read correctly and it's not 7bit encoded. My hint would be to check the encoding or use a more standard one. – Joan Albert Oct 21 '20 at 14:45
  • Did you find a solution? I am running into the same problem. Locally it is working (saving into MinIO) but with AWS S3 it does not. – Mick Jul 30 '21 at 11:14
  • The solution is in the below comment. I remember I have formatted the buffer to `base64` and it worked for me – stevenH Jul 30 '21 at 16:02

1 Answers1

1

I would suggest you to use base64 encoding, 7bit enconding won't work for images as you are trying to do.

You can read more about that in this StackOverflow answer: https://stackoverflow.com/a/28531705/6334411

Joan Albert
  • 644
  • 10
  • 23