Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

253
Vistas
FormData() converts files to String

I cannot send the original data object from my form through axios to Spring Boot as is is a single object and Spring boot cannot get the @RequestParams for it. Therefore, I am putting the data a FormData object so that it can be sent to a Spring Boot application, however, whenever I append a file to the FormData object, it converts my file array to a string.

Here is the code:

const onSubmit = async (data) => {
        console.log(data, "Form data");

        let payload = new FormData();
        payload.append("JobName", data.JobName);
        payload.append("CandidateFile", data.CandidateFile);
        payload.append("ReferenceFile", data.ReferenceFile);
        console.log(...payload, "Payload")

        for(let pair of payload.entries()) {
            console.log(typeof pair[1]);
        }

        ...

In the console, data comes back with the data object, with files included:

{JobName: 'JobName', ReferenceFile: [File], CandidateFile: [File]}

The FormData payload, in the console, is:

(2) ['JobName', 'JobName']

(2) ['CandidateFile', '[object File]']

(2) ['ReferenceFile', '[object File]']

And all three typeof of the payload values come back as:

String

Is there any way I could send the files through with FormData?

I have tried using the files both in an array, and out, yet it still gives the same result.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda