Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Content-Disposition to StreamFile #434

Open
Danteba opened this issue Apr 29, 2023 · 0 comments
Open

Add Content-Disposition to StreamFile #434

Danteba opened this issue Apr 29, 2023 · 0 comments

Comments

@Danteba
Copy link

Danteba commented Apr 29, 2023

Hello

In the function StreamFile it is not possible to set the filename of the streamed file.

So, if the streamed file is downloaded, it do not have a properly name.

It can be fixed simply adding a header with "Content-Disposition: attachment; filename=myfile.pdf", or similar.

I think that you can add something like

return streamFile("/foo.txt")
  .withStatus(200)
  .withMime("application/pdf")
  .withDisposition("attachment; filename=myfile.pdf")

Or simply adding .withHeaders() to this function:

return streamFile("/foo.txt")
  .withStatus(200)
  .withMime("application/pdf")
  .withHeaders({"Content-Disposition":"attachment; filename=myfile.pdf"})

In the meantime, I just added this to my code:
<cfheader name="Content-Disposition" value="attachment; filename=myfile.pdf" >
before "return StreamFile(...)"

And the streamed file can be downloaded with the suggested name.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant