# Published Folders

Published folders allow you to share a local folder through your Universal website. Any file within the published folder is accessible via a web request. This is helpful for storing images or other files that you want to provide via your Universal Dashboard.

## Publishing a Folder

From the `Platform/ Published Folders` page, you can click Add Published Folder. Enter the local path as well as the request path. The local path is the folder that you wish to publish. The request path is the path that the end user requests to download the files from the folder.

You can turn on authentication and authorization for the folder.

<figure><img src="https://1373299915-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8F6PrkNTG8Y34hADzKOL%2Fuploads%2Fgit-blob-b135b50e6a234df1ebe9b87b851cbcce1957b00e%2Fimage.png?alt=media" alt=""><figcaption><p>Published Folders Dialog</p></figcaption></figure>

Once the folder is published, it appears in the published folders table.

<figure><img src="https://1373299915-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8F6PrkNTG8Y34hADzKOL%2Fuploads%2Fgit-blob-347a9ed38fd90a3613ea9db907e0b831e208e12c%2Fimage.png?alt=media" alt=""><figcaption><p>Puiblished Folders Table</p></figcaption></figure>

## Download Files

You can download files that are found in the published folder by visiting the request path. To continue the example above, I could visit the following URL to download the logo.png file:

```http
http://localhost:5000/images/logo.png
```

Notice that unauthenticated requests cannot access the file.

```powershell
PS C:\src\universal\src> invoke-webrequest http://localhost:5000/images/logo.png
Invoke-WebRequest: Response status code does not indicate success: 401 (Unauthorized).
```

## Default Documents

Default documents allow you to load files when a user specifies the folder but not the document within a folder. This is handy when a user visits a URL such as `/docs` but does not specify `/docs/index.html`. Instead of returning a 404, you can return the `index.html` when the user specifies `/docs`.

To configure default documents, set the `-DefaultDocument` parameter on `New-PSUPublishedFolder`.

```powershell
New-PSUPublishedFolder -Path C:\website -RequestPath /docs -DefaultDocument @("index.hml")
```

## Impersonation

{% hint style="warning" %}
Impersonation only works when using [Windows authentication](https://docs.powershelluniversal.com/api/security#authenticating-with-windows-authentication).
{% endhint %}

By default, when PSU accesses files to serve them to users, it does so using the same service account as the process. To access files as the user that is downloading the file, turn on impersonation.

```powershell
New-PSUPublishedFolder -Path C:\website -RequestPath /docs -DefaultDocument @("index.hml") -Impersonation
```

## API

* [New-PSUPublishedFolder](https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-PSUPublishedFolder.txt)
