Contentful logo

Contentful Community

How to upload file (i.e. pdf) from form with other data

Hi,
I got stuck with the problem uploading file to Contentful (React).
So I have code:
fileUploadHandler(e){
const form = e.target;
const data = new FormData(form);

    client2.getSpace(client2.space)
    .then((space) => space.getEnvironment('master'))
    .then((environment) => environment.createEntry('document', {
        fields: {
            orderId: {
                'en-US': data.get('orderId')
            },
            user: {
                'en-US': data.get('user')
            },
            attachment: {
                 'en-US': data.get('file')
            },
            date: {
                'en-US': data.get('date')
            }
        }
    }))
    .then((entry) => entry.publish())
    .catch(console.error);
}

And form with data.
I get error:

UnknownField: {
“status”: 422,
“statusText”: “”,
“message”: “No field with id “attacment” found.”,
“details”: {
“errors”: [
{
“name”: “unknown”,
“path”: [
“fields”,
“attacment”
]
}
]
},

I was trying several ways to solve it without result.
Any suggestions?