How to convert s3Object into File and send it inside a FormData on nodeJS?

86
July 25, 2022, at 12:30 PM

so I need to download a file from S3 bucket and then, with either its buffer or readStream, append it to a FormData on node. I've tried different libraries such as formdata-node, isomorphic-form-data and form-data. Only formdata-node printed a FormData type on the log, while still having no values attached to it, and the others crashed as soon as I tried to instantiate a FormData.

const form = new FormData();
      form.set("UsuarioInclusaoDR", body.UsuarioInclusaoDR);
      form.set(
        "TipoDocumentoDigitalizadoDR",
        body.TipoDocumentoDigitalizadoDR
      );
      form.set(
        "DescDocumentoDigitalizado",
        body.DescDocumentoDigitalizado
      );
      form.set("TipoDocumento", fileType);
      form.set("NomeDocumento", file.originalname);
      form.set("Documento", {
        name: file.originalname,
        [Symbol.toStringTag]: "File",
        stream() {
          return s3Object;
        },
      });

I've tried removing the "Documento" form.set and it also didn't work. Any clues on what's impeding my FormData to get values set, or appended (i've tried both?)

Also, I'm really struggling trying to get a valid File from my S3 Buffer, is there any way to do that?

Rent Charter Buses Company
READ ALSO
How do I stop my nodejs server for test purposes?

How do I stop my nodejs server for test purposes?

my nodejs module starts a server on a specific port, I am wondering if it is a way to stop the execution of that server in my mocha test:

61
Get return from .mjs script to Python

Get return from .mjs script to Python

I need to executemjs script about 200 times with another parameters (changableParametr):

95
render page after for loop is finished node.js

render page after for loop is finished node.js

I'm having an async problem, and I've followed a lot of articles online to try and get this issue fixed, but it hasn't done anything

50
overwrite or reinstall nodejs and npm on windows

overwrite or reinstall nodejs and npm on windows

Long story short, I'd like to reinstall nodejs on my windows systemHowever after I downloaded the msi file and ran it, it failed complaining about cannot find D drive

80