Does anyone have an idea about uploading a new version of a File in Lightning Component using the base lightning component lightning:fileUpload?

I tried passing ContentDocumentId into recordId parameter, but it returns error on upload.

<lightning:fileUpload  name="fileUploader"
                           label= "Demo Upload"
                           recordId="{!v.recordId}" />
  • please share your component code including apex controller if applicable, thanks
    – glls
    Apr 16, 2018 at 21:50
  • component code was just one line, I've added to my question now.
    – VarunC
    Apr 17, 2018 at 6:54
  • What about your apex controller, this component won’t update/replace existing files on its own
    – glls
    Apr 17, 2018 at 12:39
  • I didn't had any APEX Controller. The only hook I see in docs is onuploadfinished, that happens after we upload document. What else can we do in APEX regarding this component?
    – VarunC
    Apr 17, 2018 at 12:42
  • You want to replace/update the existing attached document? So you would manage that part of the logic in your apex controller
    – glls
    Apr 17, 2018 at 12:50

1 Answer 1


This cannot be done with the lightning:fileUpload component.

I solved this problem with the lightning:openFiles event.

This way a user has a preview of the file and inside the previewer you can upload a new version, delete, download and so on:

enter image description here

Here is some code sample:


<aura:attribute name="file" type="ContentDocumentLink" description="content file - taken from server" />

<div onclick="{!c.previewFile}" id="{!file.ContentDocumentId}">
    <lightning:tile label="{!file.fileName}" title="Click to preview and manage uploaded file">
        <aura:set attribute="media">
            <lightning:icon iconName="doctype:unknown" size="xx-small"/>


previewFile: function(component, event, helper) {
    var contentId = event.currentTarget.id;
        recordIds: [contentId]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.