Business Central: How to upload and download File Attachments in Extensions

Unfortunately, in Extensions it becomes fiddly when it is necessary to upload or download File Attachments. The build-in functions of Codeunit “File Mgt.” and Table “Attachment” are not allowed to be used in Extension development. Therefor it is necessary to create own functions. The code below works in every browser.