Please enable JavaScript
Use ContentVersion entity to create files using Salesforce apex. Use ContentDocumentLink entity to link the created the file to a record in Salesforce. Blog Post: https://www.infallibletechie.com/2022/11/how-to-create-files-using-salesforce-apex.html