Reached EOF, but there is no closing MIME boundary [node.js]

Viewed 689
     const fileUploadResolverMap = {
     Mutation: {
        async uploadFiles(parent, args, context) {        
        const {messageText, conversationId, files} = args;
        let data = new FormData();
        data.append('conversationId', conversationId);
        data.append('messageText', messageText);

        for (const uploadedFile of files) {
            const file = await uploadedFile.file;
            const fileStream = await file.createReadStream();
            const attachment = await getStream.buffer(fileStream);
            const {filename, mimetype} = file;
            data.append('attachment', attachment, {filename, mimetype});
        }
        const httpClient = context.connectors['my-service'];
        httpClient._options.baseUrl = 'http://localhost:8090';
        const url = '/inbox/sendMessage';

        const options = {
            headers: {
                ...generateHeaders(context),
                ...data.getHeaders(),
            },
            operation: 'post_file_upload',
            parentContext: context.request,
            payload: data
        };
        return httpClient.post(url, options)
            .then((response) => {
                handleErrors(response);
                return response.payload;
            })
            .catch((err) => {
                err.message = `error : ${err.message} - ${url}`;
                throw err;
            });

When this call hit my service then I am always getting org.jvnet.mimepull.MIMEParsingException: Reached EOF, but there is no closing MIME boundary.

When I debug this then found that it expects last boundary in form data which is not found by my-service and throw above exception.

Please recommend me any alternative for FormData or how can I set the last extra boundary in form-data?

When I hit by postman then it is working fine.[below HTTP from postman] but when I hit from graphql partial then got exception.

    POST /inbox/sendMessage? HTTP/1.1
    Host: localhost:8090
    Content-Type: multipart/form-data; boundary=---- 
    WebKitFormBoundary7MA4YWxkTrZu0gW

    ----WebKitFormBoundary7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="conversationUUID"

   364f4667-5006-4e5c-b565-4cecebfde638
   ----WebKitFormBoundary7MA4YWxkTrZu0gW
   Content-Disposition: form-data; name="messageText"

   hiifrompostman12
   ----WebKitFormBoundary7MA4YWxkTrZu0gW
0 Answers
Related