简体   繁体   中英

Get base64 from sound url in javascript

I have a example sound url here: http://awexsoft.rf.gd/testing/test.mp3 and i want to make a base64 from this url. Is there anyway to do this?

const res = await fetch('http://awexsoft.rf.gd/testing/test.mp3');
const data = await res.arrayBuffer();

const b64 = btoa(String.fromCharCode(...new Uint8Array(data)));

console.log(b64);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM