Move upload() and uploadChunk() into the Helper with the following signature:
upload: function(component, helper file, fileContents) {...},
uploadChunk : function(component, helper, file, fileContents, fromPos, toPos, attachId) {... }
upload: function(component, helper file, fileContents) {...},
uploadChunk : function(component, helper, file, fileContents, fromPos, toPos, attachId) {... }
(notice we added the 'helper' arg)
In save() call upload() like this:
helper.upload(component, helper, file1, fileContents);
helper.upload(component, helper, file1, fileContents);
In upload(), call uploadChunk() like this:
helper.uploadChunk(component, helper, file, fileContents, fromPos, toPos, '');
helper.uploadChunk(component, helper, file, fileContents, fromPos, toPos, '');
In uploadChunk(), call uploadChunk() like this:
helper.uploadChunk(component, helper, file, fileContents, fromPos, toPos, attachId);
helper.uploadChunk(component, helper, file, fileContents, fromPos, toPos, attachId);
You may also want to take a look at this blog post to see how you can encapsulate the file upload logic in a reusable JS file: https://developer.salesforce.com/blogs/developer-relations/2016/12/lightning-components-code-sharing.html