upload file using lightning sfdmconkey

Custom File Upload In Salesforce Lightning Component – Upload Large Attachments

Lightning Component

Sharing is caring!

Hey Guys,

Today in this post we are going to learn about how to create a custom file upload salesforce lightning component. This post inspire and new updated version of ‘Peter Knolle‘ post ‘upload file component’.

For this post we are using the chunk file upload method, by this chunk file upload method we can upload large file attachments within the heap size limitation, we are using the small 750kb chunks for upload our attachment.

Using this sample code you can upload attachments upto 4.5 Mb.
Lightning Component Output Sample : 

upload file using lightning sfdmconkey

Now let’s start code …

Step 1 : Create Apex Controller : FileUploadController.apxc

From Developer Console >> File >> New >> Apex Class

  • see code comments.
Step 2 : Create Lightning Component: fileUpload.cmp 

From Developer Console >> File >> New >> Lightning Component

  • In the above lightning component on line number 10, we have a attribute called ‘parentId’ , in this attribute you have need to set the parent id, in in sample i am using the account id.
  • see code comments.

you can select or drag your file in this lightning component

JavaScript Controller : fileUploadController.js

JavaScript Helper : fileUploadHelper.js

  • see code comments.
From developer console >> file >> new >> Lightning Application
demo.app [Lightning Application]

Output:

upload file using lightning sfdmconkey

Related Resource:

Like our facebook page for new post updates. & Don’t forget to bookmark this site for your future reference.

if you have any suggestions or issue with it, you can share your thoughts  in comment box.

Happy Learning 🙂

Sharing is caring!

(Visited 11,548 times, 1 visits today)

17 comments

Leave a Reply