Skip to content

Example of how to return a file dynamically #606

@ufoscout

Description

@ufoscout

I am having a hard time trying to return binary data from one of my routes. My use case is that when a /download route is called, I need to return a file that depends on the caller profile and context.
I cannot use tower_http::services::ServeDir because in my case the file is selected dynamically. In addition, it could be served from the filesystem or from a database.

Would it be possible to include an example that shows how to:

  • return a file from the filesystem or generic binary data
  • set the response ContentDisposition/DispositionParameters/DispositionType

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions