---
schema_version: "1"
id: c383fe1864007b15c7d92ee3045bc29b3220fa0e6452988cf2062cab81e33e95
title: Open Files
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/lightning-base-components/lightning-design-system/guides/aura/components/lightning/openFiles/aura-open-files.md
canonical_url: https://developer.salesforce.com/docs/platform/lightning-component-reference/guide/aura-open-files.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: df6753d4822a3856f3c17d87f75c41fe6bfcb0118b2bb5344c1806c9006c91d5
products:
  - Lightning Component Reference
---

# Open Files

**`lightning:openFiles`**

The `lightning:openFiles` event is no longer recommended. Use the [Lightning navigation service](/docs/platform/lightning-component-reference/guide/aura-navigation.html) instead. Application event used to open one or more file records. This event triggers a modal file previewer or download depending on the form factor.

**For Use In**

Lightning Experience, Experience Builder Sites, Salesforce Mobile App

::::::tabset{tabs='[ "Develop", "Specifications"]'}

:::::tab

`lightning:openFiles` is an application event used to open one or more file records.

Firing the event opens the preview of a single or multiple files in a modal dialog when on desktop, or trigger a file download on mobile devices.

```html
<aura:component>
  <aura:handler event="lightning:openFiles" action="{! c.handleOpenFiles }" />
  <lightning:button label="Open a single file" onclick="{! c.openSingleFile }" />
  <lightning:button label="Open multiple files" onclick="{! c.openMultipleFiles }" />
</aura:component>
```

```javascript
({
  openSingleFile: function (cmp, event, helper) {
    $A.get("e.lightning:openFiles").fire({
      recordIds: ["fileid0"],
    });
  },
  openMultipleFiles: function (cmp, event, helper) {
    $A.get("e.lightning:openFiles").fire({
      recordIds: ["fileid0", "fileid1", "fileid2"],
      selectedRecordId: "fileid1",
    });
  },
  handleOpenFiles: function (cmp, event, helper) {
    alert(
      "Opening files: " +
        event.getParam("recordIds").join(", ") +
        ", selected file is " +
        event.getParam("selectedRecordId"),
    );
  },
});
```

The desktop file previewer offers image and SVG-based multi page office documents preview, presentation mode and quick access to file actions (share, download, upload, delete).

On mobile and tablet a single file is downloaded when the event is fired i.e. the one specified in `selectedRecordId` or the first element from the `recordIds` list. Depending on the device this triggers a native preview of the file.

Supported entities are ContentDocument and ContentHubItem (external files).

The `lightning:openFiles` event is supported in Lightning Experience, the Salesforce mobile app, and Experience Builder sites based on the Customer Service template.


:::::

:::::tab
## Attributes

| Name               | Description                                                                                                                                                                                                 | Type   | Default | Required                                     |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | ------- | -------------------------------------------- |
| `recordIds`        | IDs of the records to open.                                                                                                                                                                                 | string |         | ![Yes](https://developer.salesforce.com/media/check.png) |
| `selectedRecordId` | ID of the record to open first among the one specified in the recordIds attribute. If this value is not provided or if the value provided is not in the list, the first element from the list will be used. | string |         |                                              |

:::::

::::::
