Using npm GOT framework, send a POST request with no body and attach a file

Viewed 502

With the requirement of using the got framework in node.

I need to send a POST request that attatches a File and no body. This is because I am trying to send a JSON object the is bigger than the default 1MB size that nginx allows for the body size.

This code right here will send attatch a file but will also add the data to the body and cause a 413 request entity too large error

      const form = new FormData();
      form.append('files', Buffer.from(JSON.stringify(body)), {
         contentType: 'text/plain',
         filename: 'json.data',
      });
      const options = {
         method: 'POST',
         url: `${apiEndpoint}/example`,
         body: form,
      };

Any suggestions

0 Answers
Related