Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6502

corrupted file when converting base64 mp4 string buffer to blob to file

$
0
0

I made a more specific post regarding an issue in my react app but I feel like the extra details aren't necessary since I think I'm missing a general of understanding of base64 buffer to blob to file. Here's my code:

  const buffer = Buffer.from(recordingBase64, "base64");  const blob = new Blob([buffer], { type: "audio/mp4" });  const file = new File([blob], "test.mp4", { type: "audio/mp4" });  const formData = new FormData();  formData.append("file", file);  const apiUrl = "https://eokw6m8m7gihzgg.m.pipedream.net/";  const requestOptions = {    method: "POST",    headers: {      Authorization: `Bearer ${API_KEY}`,    },    body: formData,  };  fetch(apiUrl, requestOptions)    .then((response) => response.json())    .then((data) => console.log(data))    .catch((error) => console.log(error));

I've confirmed the base64 string itself is actually a working mp4 via some converting tools, but I'm not sure where it's becoming corrupted, can someone point out what I'm doing wrong?


Viewing all articles
Browse latest Browse all 6502

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>