title: How to convert a blob file to a specific format?
body: <p>I am building a web application with ReactJS and Django framework.</p>
  <p>In this web application, there is a part where I record an audio file and send it to the backend to save it.</p>
  <p>This is the blob data from ReactJS that I send:</p>
  <pre><code>Blob {
  size: 29535, 
  type: &quot;audio/wav; codecs=0&quot;
  }
  </code></pre>
  <p>And this is the code I am using in the backend:</p>
  <pre><code>@api_view(['POST'])
  @csrf_exempt
  def AudioModel(request):
      try:
          audio = request.FILES.get('audio')
      except KeyError:
          return Response({'audio': ['no audio ?']}, status=HTTP_400_BAD_REQUEST)
  
      destination = open('audio_name.wav', 'wb')
      for chunk in audio.chunks():
          destination.write(chunk)
      destination.close()  # closing the file
  
      return Response(&quot;Done!&quot;, status=HTTP_200_OK) 
  </code></pre>
  <p>When I play the file I saved, it plays some sound but it crashes when it achieves the end.</p>
  <p>This problem makes me look for some information about the file I saved (extension,...).</p>
  <p>For this reason I used <code>fleep</code> library:</p>
  <pre><code>import fleep
  
  with open(&quot;audio_name.wav&quot;, &quot;rb&quot;) as file:
      info = fleep.get(file.read(128))
  
  print(info.type)
  print(info.extension)
  print(info.mime)
  </code></pre>
  <p><strong>OUTPUT:</strong></p>
  <pre><code>['video']
  ['webm']
  ['video/webm']
  </code></pre>
  <p>But getting video in output!</p>
  <ul>
  <li>Am I doing something wrong?</li>
  <li>How can I fix this issue?</li>
  <li>Is there anything I can use to save my file in the desired format?</li>
  </ul>
  <p>Any help is appreciated.</p>
  <p><strong>EDIT:</strong></p>
  <p>Output of first 128 bytes of the saved file:</p>
  <pre><code>b'\x1aE\xdf\xa3\x9fB\x86\x81\x01B\xf7\x81\x01B\xf2\x81\x04B\xf3\x81\x08B\x82\x84webmB\x87\x81\x04B\x85\x81\x02\x18S\x80g\x01\xff\xff\xff\xff\xff\xff\xff\x15I\xa9f\x99*\xd7\xb1\x83\x0fB@M\x80\x86ChromeWA\x86Chrome\x16T\xaek\xbf\xae\xbd\xd7\x81\x01s\xc5\x87\xbd\x8d\xc0\xd5\xc6\xaf\xd0\x83\x81\x02\x86\x86A_OPUSc\xa2\x93OpusHead\x01\x01\x00\x00\x80\xbb\x00\x00'
  </code></pre>