I've used the followed example to upload files in my app:
http://peterknolle.com/file-upload-lightning-component/
At the Helper upload method, I've found the '$A.run' and it's not working anymore, so I took it off. And now, when I select the file to upload at the first time nothing happens, but if I do it again both files are uploaded. Summing up: Code inside 'setCallback' are only executed if upload twice.
upload: function(component, file, fileContents) {
var action = component.get("c.saveTheFile");
action.setParams({
parentId: component.get("v.parentId"),
fileName: file.name,
base64Data: encodeURIComponent(fileContents),
contentType: file.type
});
action.setCallback(this, function(a) {
attachId = a.getReturnValue();
console.log(attachId);
});
$A.run(function() {
$A.enqueueAction(action);
});
}
Is there any idea to solve my problem?