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

297
Views
Cómo publicar binarios en Python para la API de Strapi

Para Strapi, me dan este modelo de JavaScript para cargar un archivo desde un formulario. Para obtener más información, consulte aquí: https://docs.strapi.io/developer-docs/latest/plugins/upload.html#upload-files-related-to-an-entry

 const formElement = document.querySelector('form'); formElement.addEventListener('submit', (e) => { e.preventDefault(); const request = new XMLHttpRequest(); request.open('POST', '/upload'); request.send(new FormData(formElement)); });

Estoy escribiendo un programa en Python. ¿Cómo traduzco esto en Python? . No estoy usando un formulario, estoy extrayendo el archivo de una ubicación en el disco.

Pero hay una advertencia en la documentación: You have to send FormData in your request body.

Esto es lo que tengo hasta ahora:

 url = f"{strapi_server_url}/api/upload" headers = { 'Authorization': f"Bearer {jwt}", } file=open(os.getcwd() + f'\\toys\\{filename}', 'rb') data = file.read() print(f"LENGTH FILE: {len(data)}") response = requests.post(url,files={'file': data}, headers=headers)

Me sale un error 400. 'ValidationError': 'Los archivos están vacíos'. Pero verifiqué la longitud de la variable 'datos': 5 MB.

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!