Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
No se puede cargar el archivo usando formik. La API del cartero está funcionando

He creado debajo de la API. funciona perfectamente desde cartero.

 @Controller('certificates') export class CertificatesController { constructor(private readonly certificatesService: CertificatesService) {} @Post('upload') @UseInterceptors( FileInterceptor('attachedFile', { storage: diskStorage({ destination: './uploads', filename(_, file, callback) { const randomName = Array(32) .fill(null) .map(() => Math.round(Math.random() * 16).toString(16)) .join(''); return callback(null, `${randomName}${extname(file.originalname)}`); }, }), }) ) uploadFile(@UploadedFile() file) { console.log(file); return { url: `http://localhost:8000/api/uploads/${file.filename}`, }; } }

cuando lo llamo usando cartero ingrese la descripción de la imagen aquí

pero cuando quiero llamar al mismo usando formik, mi API recibe indefinido en el archivo.

 <input id="file" name="attachedFile" type="file" onChange={(event: any) => { setFieldValue( 'file', event.currentTarget.files[0] );}} /> const handleSubmit = async (values: any, httpClient: any, config: any) => { alert(values.attachedFile); //it prints Object filelist const { data } = await axios.post( 'http://localhost:3000/api/certificates/upload', values.attachedFile );

mi API devuelve el siguiente error y en la interfaz de usuario obtengo 500.

ingrese la descripción de la imagen aquí

¿Por qué no puedo enviar el archivo junto con la solicitud de publicación? debo hacer otra cosa? Aparte del archivo en otra solicitud, puedo enviar todos los datos. ¿Puedes ayudarme?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!