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

Allow custom content-type header for sending files #2641

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

321hendrik
Copy link
Contributor

Makes it possible to configure the content-type header before sending a file.

Use case:

  • There is a file named test.png_preview
  • Mimetype can not be inferred from file extension
  • You want to specify the type yourself in the download action

@evantahler
Copy link
Member

evantahler commented Nov 3, 2023

I understand your use-case, and I agree we should allow for a way to make this change. I think that I would prefer the server/action be in control of if we want to set a custom mimeType rather than relying on a user request's header (which could be anything), e.g.:

await data.connection.sendFile("logo/actionhero.png", {mimeType: "application-foo"});

If the sendFile method were changed instead, then application could verify that the mimetype that is was about to set was valid/reasonable vs just passing back whatever the user requested... which could get folks into trouble (e.g. application/x-msdownload)

@evantahler
Copy link
Member

Ping! Are you still interested in working on this?

@321hendrik
Copy link
Contributor Author

321hendrik commented Nov 28, 2023

I tried to implement your suggestion. Is this how you imagined?
The mimetype validation is just an example, could be more strict.

As for my use-case, I do not want to set a mimetype from user input. I want to be able to set a specific mimetype in my action. Maybe the test is misleading here.

Copy link
Member

@evantahler evantahler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your implementation is 👍, but I think modifying the sendFile action ins misleading here, because we don't really want this behavior in the action. You could make a new mock action in the test (e.g.) with that tests the behavior

@evantahler
Copy link
Member

Hello! Checking in again to see if you need help

@evantahler evantahler added the enhancement New feature or request label Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants