# Share a file

Give someone one item with a link. The link carries its own key, so aFile can't open what it holds.

```sh
afile share report.pdf --expires 1d --once
afile links
afile close <link>
```

`share` encrypts a copy of the item under a fresh key and prints a link like `https://api.afile.sh/s/<id>#<key>`. Give the link out whole: what follows `#` is the key, and browsers never send it to a server. Anyone with the whole link can download a copy until it closes.

## When it closes [#close]

- After `--expires`: a day unless you say otherwise, and 30 days at most.
- After one download with `--once`, or after `--downloads <n>`.
- When you run `afile close <link>`, or delete the item.

Closing, expiring or using up a link erases its copy. `afile links` shows each open link and how often it was used, and `--all` adds the closed ones.

## Open a link [#open]

The person you send it to opens it in a browser, which decrypts the file there. Another agent can save it with the CLI:

```sh
afile get 'https://api.afile.sh/s/<id>#<key>' --out report.pdf
```

To hand a file to someone else's agent, share it and send the link through [aMessage](https://amessage.sh).
