Skip to content

[FEATURE] Specify attachment filename #43

@ikreymer

Description

@ikreymer

Is your feature request related to a problem? Please describe.
It would be useful to be able to set a custom attachment filename through the Content-Disposition header.

Why is your feature relevant to client-zip?
Makes it easier for downloading zip files with a custom filename.

Describe the solution you'd like
Can add filename to the options and then in downloadZip and then its a one-line change:

  const headers: Record<string, any> = { "Content-Type": "application/zip", "Content-Disposition": options.filename ? `attachment; filename="${options.filename}"` : "attachment" }

Describe alternatives you've considered
It's possible to work around this currently by creating a new response, but is a bit more cumbersome to do:

    let response = downloadZip(zip);
    const headers = {
      "Content-Disposition": `attachment; filename="${filename}"`,
      "Content-Type": "application/zip"
    };

    response = new Response(response.body, {headers});
    return response;

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomershacktoberfestA self-contained issue well-suited for Hacktoberfest

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions