Convert Base64 to ByteArray

we have a field in our collection, defines as “binData” , it is saved a Base64 in mongoDB atlas.
I need to convert this field into ByteArray ( and send it to S3 bucket )
Could not figure a way to do so , any ideas ?
Ran