To answer your question on buffer, you do this:
const fetch = require('node-fetch'); //NPM package I like using but you can use wix-fetch
let buffer = await create_buffer(); //This is the buffer
let encoded_file = await encoder(buffer); //This is the base64 encoded result
const create_buffer = () => {
return fetch(YOUR_URL, {
method: 'GET',
encoding: null
})
.then( (res) => {
return res.buffer(); //This is the buffer
});
}
const encoder = (string) => {
var encryptedBytes = Buffer.from(string);
var encoded = encryptedBytes.toString('base64');
return encoded;
}
But you will not be able to directly upload a file without going thru the wix media manager natively, with custom html code or custom element you may be.