node-sdk icon indicating copy to clipboard operation
node-sdk copied to clipboard

Help with file redirect responses

Open jyecusch opened this issue 3 years ago • 0 comments

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);
});

jyecusch avatar Mar 04 '22 05:03 jyecusch