When I'm uploading an attachment every time, on Clicking of the Save button which calls the function using javascript in Lightning Component, it creates an Instance of an Object whose ParentId I'm considering for Attachment and a single Attachment is getting uploaded to Notes & Attachment related List. What I want in a single run all the attachments should be placed inside a single Instance of Object.
Public static account temp = new account();
@AuraEnabled
public static Id saveTheFile(Id parentId, String fileName, String base64Data, String contentType) {
system.debug('Before method call');
base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
system.debug('saveTheFile method call');
update temp;
system.debug('TEMP ID === ' + temp.id);
Attachment addAtt = new Attachment();
addAtt.Body = EncodingUtil.base64Decode(base64Data);
addAtt.ParentId = temp.Id;
addAtt.Name = fileName;
addAtt.ContentType = contentType;
attList.add(addAtt);
insert attList;
return attList[0].id;
}