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

122
Views
Subir imagen desde el almacenamiento local a la API

Supongamos que tengo una API que toma una imagen y la procesa. Ejemplo:

 @app.post("/upload/") async def upload_image(file: UploadFile = File(...)): file_content = await file.read() print(file_content) extension = file.filename.split(".")[1] if extension not in ["png", "jpg"]: return {"status": "error", "detail": "File is not supported"} ocr_result = ocr(file_content) return {"filename": file.filename, "text": ocr_result}

Y quiero hacer una solicitud de publicación para esto usando axios cargando una imagen desde mi almacenamiento local. Así que hice esto:

 let file = fs.createReadStream('discount.jpg') let data = new FormData(); data.append('file', file, 'discount.jpg'); axios.post('http://127.0.0.1:8000/upload/', data, { headers: { 'Content-Type': 'multipart/form-data' } }).then(function() { console.log(response.data); })

Pero esto no parece estar funcionando. ¿Alguna idea de qué estoy haciendo mal?

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!