Skip to content

Add something like Flask's send_file to Werkzeug #265

Closed

Description

@TomiBelan

Flask's send_file takes a file name or object and returns a response that can be used to send this file to the client. Werkzeug doesn't have any analogue -- SharedDataMiddleware is the closest, but its API is better suited to serving directories and it doesn't have many of send_file's useful options.

Flask tends to build on Werkzeug, but that's not the case with send_file -- it's lower-level than most of Flask. It'd be better if Werkzeug contained the base functionality and Flask just provided the framework integration (like send_from_directory and get_send_file_max_age). And perhaps SharedDataMiddleware could use this common base too (right now they both have to deal with generating etags, etc).

Activity

  1. amigrave commented on Sep 2, 2014

    @amigrave
    Contributor

    Indeed !

    I'm used to @mitsuhiko 's style that emphasis reusability but unfortunately it seems he missed that one.

  2. davidism commented on Apr 12, 2020

    @davidism
    Member

    @pgjones pointed out that we should make Werkzeug's send_file implementation sans-io, so that it can be used with ASGI. Maybe he can elaborate on a design, but we'll need something where we can pass in data incrementally rather than passing an open file.

  3. roeeyn commented on Jun 15, 2020

    @roeeyn
    Contributor

    I will be working in this issue 😄

  4. added this to the 2.0.0 milestone on Jul 13, 2020
  5. locked as resolved and limited conversation to collaborators on Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions