Skip to content

Help with file redirect responses #106

@jyecusch

Description

@jyecusch

When responding to API requests with a file a convenience method would be nice that sets the appropriate response headers for a redirect and returns the pre-signed read URL.

Dev experience should be something like this:

import { api, bucket } from "@nitric/sdk";

const files = bucket('files').for('reading');
const fileApi = api('file-api');

fileApi.get("/files/:filename", async (ctx) => {
  const { filename } = ctx.req.params;
  const file = files.file(filename)
  ctx.res.file(file);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions