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

238
Views
enviar blob al matraz de python y luego guardarlo

Entonces, estoy tratando de crear un sitio web que grabe su voz, el problema es que cuando envío a un servidor de matraz el archivo blob o la URL del blob, mi código python del matraz dice que no hay contenido mientras lo es, ¿cómo puedo enviar? el blob, para que el servidor pueda guardarlo como un archivo.

 mediaRecorder.addEventListener("stop", () => { const audioBlob = new Blob(audioChunks, { type: "audio/wav" }) const audioUrl = URL.createObjectURL(audioBlob); const audio = new Audio(audioUrl); audio.play(); var data = new FormData() data.append('file', audioUrl) fetch('http://127.0.0.1:5000/receive', { method: 'POST', body: data }).then(response => response.json() ).then(json => { console.log(json) });

y mi código de matraz de python:

 @app.route("/receive", methods=['post']) def form(): files = request.files file = files.get('file') print(file) with open(os.path.abspath(f'backend/audios/{file}'), 'wb') as f: f.write(file.content) response = jsonify("File received and saved!") response.headers.add('Access-Control-Allow-Origin', '*') return response

¿Hay una manera de hacerlo? ¿Enviar un archivo de blob de registro, descargarlo en python?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El problema está en esta línea:

 data.append('file', audioUrl)

no usa FormData.append de la manera correcta. debería ser:

 data.append('file', audioBlob , 'file')

Consulte la documentación: https://developer.mozilla.org/en-US/docs/Web/API/FormData/append

about 4 years ago · Juan Pablo Isaza Report
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!