Skip to content

(HelpWanted) Reuse the binary to make a request #20

@refucktor

Description

@refucktor

First of all, great job! this library help from having a hell of parsing multipart/form-data.
I'm now facing a very strange situation, my lambda function it's just an interface between a client and an API, I'm using your library to parse the incoming data and, make some operations and then post a different object to the API. My function looks like this

const axios = require('axios');
const multipart = require('aws-lambda-multipart-parser');
module.exports.run = async event => {
    try {
        /* sample of json
            {name: 'test_a', something: 'test_b', documents: ''}
        */
        const data = multipart.parse(event, false);

        /* data.documents has the file(s) */
        const result = await someOperation(data);
        const response = axios.post('http://example.com/results', result);
        return {
            statusCode: 200,
	    body: JSON.stringify(response.data),
        }
        } catch (e) {
            return {
                statusCode: 500,
	        body: JSON.stringify({
                    message: e.message,
                    stack: e,
            }),
        }
    }
};

My problem is that I need to reuse the files to make the last request. So far I'm failing on every try and I will appreciate your help a lot! Any idea is more than welcome.
Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions