--- title: "locker.download" slug: "app-locker-download" updated: 2025-11-06T19:14:24Z published: 2025-11-06T19:14:24Z canonical: "docs.doc-know.com/app-locker-download" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.doc-know.com/llms.txt > Use this file to discover all available pages before exploring further. # locker.download ### app.locker.download Initiates an asynchronous download of a specified **resource** from your app's [locker](http://docs.doc-know.com/v1/docs/app-locker). When downloading completes, the resource is stored inside the runtime's [cache](http://docs.doc-know.com/v1/docs/cache-intro) object using the resource's locker token as a **key**. An alternative key can be specified, if desired. The [Ux.ResourceReady](http://docs.doc-know.com/v1/docs/events) event is triggered so you can take action when your resource becomes available. ### Input Parameters | Name | Type | Required | Description | | --- | --- | --- | --- | | **token** | Text | Yes | Resource's [locker](http://docs.doc-know.com/v1/docs/app-locker) token | | **[key]** | Text | No | Unique [cache](http://docs.doc-know.com/v1/docs/cache-intro) key where resource will be stored; Default = resource's **locker token** | | **[type]** | Text | No | Type of data being downloaded | The following types are supported: | Name | Description | | --- | --- | | **text** | Plain text (**default**) | | **json** | JSON object | | **xml** | XML document | | **image** | Platform-specific image object | | **bits** | Raw binary data | ### Returns No return value. ### Examples ``` // inside the Ux.Initialize script... // download resource from app's locker app.locker.download("TOKEN"); ``` ``` // inside the Ux.Initialize script... // download resource from app's locker, specifying a custom cache key app.locker.download("TOKEN", "config"); ``` ``` // inside the Ux.ResourceReady script... // note: this script will run once for each downloaded resource // note: demonstrates how to take action immediately after download completes // get the cache key for this downloaded resource var key = script.args[0]; // fetch the downloaded resource from cache var item = cache.get(key); ``` ``` // inside any script (i.e. Ux.Change)... // note: demonstrates how to manually check for resource anytime // check if resource is available if (cache.exists("TOKEN") === true) debug.log("Resource exists."); ``` ### Remarks Use this function when you need to download resources from your app's locker such as files, configurations, lookup tables, raw data, or images. Downloading resources from your app's [locker](http://docs.doc-know.com/app-locker) instead of the open internet is strongly recommended since they are fully managed by the app platform. One common scenario is to download a file using the [Ux.Initialize](http://docs.doc-know.com/v1/docs/events) event. Once downloaded, you can take action using the [Ux.ResourceReady](http://docs.doc-know.com/v1/docs/events) event. The [cache](http://docs.doc-know.com/v1/docs/cache-intro) **key** you provided is accessible via the runtime's [script](http://docs.doc-know.com/v1/docs/script-intro2) object. Two-Step Process Downloading resources can be slow based on connection speeds and the size of the resources being downloaded. Because of this speed issue, downloading resources requires a two-step process. First, you must initiate the download (from one script). Second, you take action (if needed) after the download completes from another script (i.e. [Ux.ResourceReady](http://docs.doc-know.com/v1/docs/events)). By separating these steps, the user's experience remains fluid. Otherwise, the user interface would freeze until the download completes, resulting in a poor user experience.