node-sdk
node-sdk copied to clipboard
Help with file redirect responses
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);
});