I've used the followed example to upload files in my app:

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"); 

        parentId: component.get("v.parentId"),
        fileName: file.name,
        base64Data: encodeURIComponent(fileContents), 
        contentType: file.type

    action.setCallback(this, function(a) {
        attachId = a.getReturnValue();

    $A.run(function() {

Is there any idea to solve my problem?

1 Answer 1


The code you used is out of date now, $A has been deprecated, you now need to use $A.getCallback() instead. I've not dug deeply into this, but pretty sure this'll sort you out:

$A.getCallback(function() {
  • Thank you @MattLacey ... Your solution fixed my problem! Mar 17, 2017 at 14:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .