Thank you for your replies and ideas, I appreciate it.
In the end, I found out about the Machines API’s execute command endpoint and now I use that along the lines of:
python -c import base64; open('TARGET_FILE_PATH', 'w').write(base64.b64decode('FILE_B64').decode('utf-8'));
Obviously, this requires python on the target machine but python is part of the image my target machine is running. The b64 decoding could certainly be done in a similar way with another programming language - maybe even with bash.