
# Share files and links

Every file in a bucket is **private** until you decide otherwise. A private file can only be read with your [credential](/docs/storage-buckets/credentials) or through a temporary link. A public file can be opened by anyone who has its link.

## Public and private files

Each file row has a lock icon. Hover over it to see the file's current state.

| | Private | Public |
|---|---|---|
| Who can open it | You, with a credential, or anyone you gave a temporary link | Anyone with the link |
| Link | Temporary, expires after a short time | Permanent |
| Good for | User uploads, invoices, internal documents | Images on a website, downloads you publish |

To change a file:

1. Select the lock icon on the file's row. A window shows whether the file is **Public** or **Private**.
2. Select **Make public** or **Make private**. The change applies immediately.
3. Select **Done**.

Visibility belongs to each file. Making one file public does not affect the rest of the bucket.

### Uploading over an existing file

A file you upload is always private, **including when it replaces a public file with the same name**. If you replace a public file, make the new one public again.

## Links

Select **Copy link** on a file's row, or open the lock icon's window and use the **Copy** button next to a link.

### Permanent link for a public file

A public file has one link that does not expire, shown as the **Permanent link**. It looks like this:

```text
https://buckets.kuberns.cloud/public/kb-product-assets-3f9a1c2b7d4e/logo.png
```

You can put it in a web page, an email, or an `<img>` tag.

### Temporary link for a private file

A private file has no permanent address. Its **Temporary link** works in any browser **without a credential**, for a short time (ten minutes by default), and then stops working. Use it to hand a file to one person, and create a new link when they need it again.

A temporary link keeps working until it expires, even if you change the file afterwards. If you need a link that keeps working, make the file public instead.

## Make a public file private again

Open the lock icon's window and select **Make private**. The permanent link stops working. Links are served from a global network, so a cached copy can stay available for a short time while that network catches up. In practice the link stops working within about a minute.

Anyone who has already downloaded the file keeps their copy. Making a file private does not take it back from them.

## Do it from your code

You can read and change a file's visibility and create links with the [API](/docs/storage-buckets/api-reference):

- [Get a link](/docs/storage-buckets/api-sharing#get-a-link) returns the right kind of link for a file, whatever its state.
- [Set visibility](/docs/storage-buckets/api-sharing#set-visibility) makes a file public or private.
