L
L
levnikrot2021-05-05 12:09:21
Node.js
levnikrot, 2021-05-05 12:09:21

How to add an end border in a compound body?

Compose a FormData object and send

const data = new FormData();

            data.append('key', `${info.KeyPrefix}jpg/${hash}.jpg`);
            data.append('acl', info.ACL);
            data.append('policy', info.PolicyBase64);
            data.append('signature', info.Signature);
            data.append('GoogleAccessId', info.AccessKey.Value);
            data.append('Cache-control', info.AdditionalBody[0].Value);
            data.append('Content-Type', 'image/jpeg');
            data.append('file', fs.readFileSync('./x.jpg').toString());

            const result = await axios.post(info.BaseURL, data, {
                headers: {
                    'content-length': size.toString(),
                    'content-type': `multipart/form-data; boundary=${data._boundary}`,
                    'ngsw-bypass': 1,
                    'User-Agent': this.cfg.requestOptions.headers['User-Agent'],
                }
            });


Then comes the error response:
Missing end boundary in multipart body.


I assume that is missing at the end of the line by type
--------------------------175683790495608555919250--


60925fe657c35969600016.jpeg

like here

60926089d03ca985469418.jpeg

Only I don't know how to add it correctly.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question