Skip to content
This repository was archived by the owner on Sep 12, 2019. It is now read-only.
This repository was archived by the owner on Sep 12, 2019. It is now read-only.

Bug: netlify dev mangles base64 upload #143

@sanderhahn

Description

@sanderhahn

- What is the current behavior?

Binary file upload base64 is mangled when uploaded to netlify dev. The same upload to a deployed site works correctly. The binary is a transparant png for demo purposes:

$ base64 pixel-transparent.png
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGP6zwAAAgcBApocMXEAAAAASUVORK5CYII=

The function just displays the base64 data that is made available:

exports.handler = async function (event, context) {
    return {
        statusCode: 200,
        body: JSON.stringify({
            base64: event.isBase64Encoded,
            data: event.body,
        }),
    };
};

- If the current behavior is a bug, please provide the steps to reproduce.

Upload to netlify dev site:

$ curl -X POST -H "Content-Type: image/jpeg" --data-binary "@pixel-transparent.png" http://localhost:8888/.netlify/functions/body
{"base64":true,"data":"77+9UE5HDQoaCgAAAA1JSERSAAAAAQAAAAEIBAAAAO+/vRwMAgAAAAtJREFUeO+/vWPvv73vv70AAAIHAQLvv70cMXEAAAAASUVORO+/vUJg77+9"}

- What is the expected behavior?

Upload to deployed site:

$ curl -X POST -H "Content-Type: image/jpeg" --data-binary "@pixel-transparent.png" https://{site_id}.netlify.com/.netlify/functions/body
{"base64":true,"data":"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGP6zwAAAgcBApocMXEAAAAASUVORK5C"}

OS: mac
Node: v10.11.0

Thanks for making Netlify!
Works great :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions