import { setFilename } from "https://deno.land/x/ayonli_jsext@v0.9.72/http.ts";
Sets the Content-Disposition
header with the given filename when the
response is intended to be downloaded.
This function encodes the filename with encodeURIComponent and sets
both the filename
and the filename*
parameters in the header for maximum
compatibility.
NOTE: This function can be used with both Response and Headers
objects. However, when using with a Headers
instance, make sure to set the
filename before the headers instance is used by the response object.
Examples
Example 1
Example 1
import { setFilename } from "@ayonli/jsext/http";
export default {
fetch(req: Request) {
const res = new Response("Hello, World!");
setFilename(res, "hello.txt");
return res;
}
}