lightning:openFiles

Opens one or more file records from the ContentDocument and ContentHubItem objects.

On desktops, the event opens the SVG file preview player, which lets you preview images, documents, and other files in the browser. The file preview player supports full-screen presentation mode and provides quick access to file actions, such as upload, delete, download, and share.

On mobile devices, the file is downloaded. If the device supports file preview, the device’s preview app is opened.

This example opens a single file.

openSingleFile: function(cmp, event, helper) {
    $A.get('e.lightning:openFiles').fire({
        recordIds: [component.get("v.currentContentDocumentId")]
    });
}

This example opens multiple files.

openMultipleFiles: function(cmp, event, helper) {
    $A.get('e.lightning:openFiles').fire({
        recordIds: component.get("v.allContentDocumentIds"),
        selectedRecordId: component.get("v.currentContentDocumentId")
    });
}
Note

Note

This event is supported in Lightning Experience, the Salesforce1 mobile browser app, and Lightning communities. It isn’t supported in the deprecated Koa and Kokua community templates.

Attribute Name Type Description
recordIds String[] Required. IDs of the records to open.
selectedRecordId String ID of the first record to open from the list specified in recordIds. If a value isn’t provided or is incorrect, the first item in the list is used.