I'm currently having a trouble to understand how to access the fileSize variable to use in another async function. I need the value of fileSize in order to upload a media. Below here is the code containing the fileSize variable.
async function getMedia(url, auth) {
const getImage = {
    url: url,
    oauth: auth,
};
var downloadImage = get(getImage).then(function(response) {
    let imageBuffer = Buffer.from(response.body);
    let imageBase64 = imageBuffer.toString('base64');
    let decodedBase64 = atob(imageBase64);
    let fileSize = decodedBase64.length;
    //console.log(fileSize);
});
await downloadImage;
};
I want to access it in another async function, like this
async function uploader() {
const uploadImageInit = {
    url: 'https://upload.twitter.com/1.1/media/upload.json',
    command: 'INIT',
    total_bytes: fileSize, // access it here
    media_type: 'image/jpeg'
};
I tried using it like this
getMedia().then((response) => console.log(response.fileSize));
But it only return an undefined. Any idea how to do it correctly?
 
    