Trouble AWS S3 download passing to downstream nodes

I had a lot of trouble passing the content of a file that I downloaded from AWS S3. It turns out that AWS S3 downloads this as binary, not json. I had to use “Extract from File (Move file to base 64 string)” node, Then a code node with the following code:

// Assume the base64 string is stored in a JSON field called "data"
const base64String = $input.item.json.data || "";

// Decode the base64 string into a UTF-8 text string
const decodedText = Buffer.from(base64String, 'base64').toString('utf8');

return { json: { text: decodedText } };

Only then could I see the content of the S3 file further downstream

Is there a more elegant way? If not I hope this helps someone.

Blessings