I need to input a CSV file using <input type='file'>
from an Lightning Component and pass it to an Apex Controller for further processing.
Component
<input type="file" aura:id="file-upload-input" id="file-upload" class="slds-file-selector__input slds-assistive-text" onchange="{!c.fileSelected}"/>
JS Controller
fileSelected : function(component, event, helper) {
var fileInput = component.find("file-upload-input").getElement();
var file = fileInput.files[0];
console.log('file'+file);
var action = component.get("c.passFile");
action.setParams({ file : file } );
action.setCallback(this, function(actionResult) {
console.log((actionResult.getReturnValue()));
// component.set("v.emailStr", actionResult.getReturnValue());
});
$A.enqueueAction(action);
}
Apex Controller
@AuraEnabled
public static void passFile(Blob file)
{
System.debug('Inside Apex');
System.debug('file'+file);
}
This gives an Salesforce Internal Error