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

Corrupted files after being parsed #7

Open
ghost opened this issue Jun 14, 2021 · 6 comments
Open

Corrupted files after being parsed #7

ghost opened this issue Jun 14, 2021 · 6 comments

Comments

@ghost
Copy link

ghost commented Jun 14, 2021

Hello,

I am having an issue where my files are being corrupted. I have checked the previous issues and made sure "Binary Media Types" are correct:
image

I have also made sure Lambda proxy is setup:
image

Any ideas as to what my issue is?

@Davste93
Copy link

Davste93 commented Aug 5, 2021

To anyone else who sees this, you probably didn't pass on the content type and accept properties inside the API gateway.
The response you should be getting should be base64.

@cabraljv
Copy link

same problem here

@courtyenn
Copy link

@cabraljv I solved this by following the instructions here: https://stackoverflow.com/a/62819124/1786840

... Don't forget to hit "Deploy API".

@michari
Copy link

michari commented Apr 12, 2023

It's not working, I see no proper solution can anyone suggest how to solve it?

  • Use Lambda Proxy Integration is enabled
  • Add Binary Media Type
  • Even followed the above stackoverflow instructions

Still does not work.

If the file is 30Kb when I pass it to S3 and save it its only 27.8Kb

I get this when I print the file object but I use the same content for S3 body the file is corrupted.

{
    content: <Buffer fd fd fd fd 00 10 4a 46 49 46 00 01 01 00 00 48 00 48 00 00 fd fd 00 40 45 78 69 66 00 00 4d 4d 00 2a 00 00 00 08 00 01 fd 69 00 04 00 00 00 01 00 00 ... 445388 more bytes>,
    filename: 'MyImage.jpg',
    contentType: 'image/jpeg',
    encoding: '7bit',
    fieldname: 'image'
}

@Vibinreji
Copy link

Hi @michari Did you resolve the issue? Now I am facing the same issue.Could you please help me if you found any solution?

@Shadowstep33
Copy link

Shadowstep33 commented Oct 31, 2023

For me anyways, the issue was for sure the binary media supported in API Gateway. You can do this by hand by going to API Gateway -> {Your API} -> Settings -> Edit -> Binary Media Types
Make sure to use multipart/form-data and not /multipart/form-data as the placeholder text might misleadingly suggest. You can also do this automatically via SAM in your template as shown below

sam-template.yaml

Globals:
    Api:
        BinaryMediaTypes:
            - multipart/form-data

@ghost @michari @Vibinreji

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

6 participants