# Download (https://v2.s3.dimah.dev/docs/react/custom-backend/download)

`download` returns a GET URL. The default is a short-lived S3 URL with
`mode: "presign"`. A backend that streams the body itself returns a
same-origin URL with `mode: "proxy"`.

The payload has `route`, `key`, and optional `name`, `disposition`, and
`expiresIn`. `name` is the file name for `Content-Disposition`. `expiresIn` is
a requested TTL in seconds: sign the shorter of that value and your route's
cap.

<AutoTypeTable
  path="packages/core/src/types/requests.ts"
  name="DownloadPayload"
/>

Return the `disposition` you signed. In presign mode, return the `expiresIn`
you actually signed: `useObjectUrl` uses it to refresh the URL before it
expires. Leave it out in proxy mode.

<AutoTypeTable
  path="packages/core/src/types/responses.ts"
  name="DownloadPresignResponse"
/>

## Example [#example]

[`@dimah-s3/server`](https://v2.s3.dimah.dev/docs/server) uses
`GET /api/s3/presign/download?route=…&key=…`.

```ts title="lib/s3-api/download.ts"
import type {
  DownloadPayload,
  DownloadPresignResponse,
  S3RequestOptions,
} from "@dimah-s3/core";
import { $fetch, call } from "./fetch";

export const download = (
  payload: DownloadPayload,
  options?: S3RequestOptions,
) =>
  $fetch<DownloadPresignResponse>("/download", {
    method: "GET",
    query: payload,
    ...call(options),
  });
```

`$fetch` and `call` come from the
[skeleton](https://v2.s3.dimah.dev/docs/react/custom-backend#skeleton).
