dimah-s3v1.5.5
Bring your own backend

Download

download — return a presigned GET URL for an object key.

download returns a GET URL. The default is a short-lived S3 URL. When the route uses download.mode: "proxy", the URL is same-origin and the server streams the body.

The payload is a single object: route, key, and optional fileName / disposition.

Prop

Type

Prop

Type

import type { DownloadPayload, DownloadPresignResponse } from "@dimah-s3/core";

Example

Add this to the defineApi skeleton. @dimah-s3/server uses GET /api/s3/presign/download?route=…&key=….

async download(payload) {
  const params = new URLSearchParams({
    route: payload.route,
    key: payload.key,
  });
  if (payload.fileName) params.set("fileName", payload.fileName);

  const res = await fetch(`/api/files/presign/download?${params}`);
  if (!res.ok) throw new Error(await res.text());
  return res.json();
}

On this page