Giter Club home page Giter Club logo

Comments (4)

Dreamsorcerer avatar Dreamsorcerer commented on September 25, 2024

If you'd like to make a PR to revert that section and include a test that exhibits the problem, we can probably include it.
I'm still not entirely clear why this fails though, I'm curious what the subclass does that breaks when converting to a Path.

from aiohttp.

kohtala avatar kohtala commented on September 25, 2024

If you'd like to make a PR to revert that section and include a test that exhibits the problem, we can probably include it.

I created a draft PR. It needs some more thought and work. It just reverts the change, but that is not right solution because it also reverts support for all os.PathLike. It would need to create a pathlib.Path for those that are os.PathLike, but not already compatible with pathlib.Path.

I'll probably add @runtime_checkable to the PathlibPathLike or some hasattr calls to see if the passed object has required pathlib.Path attributes before using it as is.

I'm still not entirely clear why this fails though, I'm curious what the subclass does that breaks when converting to a Path.

The subclass of pathlib.Path replaces stat and open such that it can make the response without the file being on filesystem. The file is created in-memory and having to write it to filesystem just to make a response is pointless. pathlib.Path fails since it can not find it on the filesystem.

from aiohttp.

steverep avatar steverep commented on September 25, 2024

I use web.FileResponse to respond with a file that is not really on the disk. This is done with a Path instance that implements the pathlib.Path interface.

What's the actual data? Are you opening a file and just want to keep it open? It would not be terribly difficult to allow the constructor to also accept a file object, in particular an instance of BufferedIOBase. The user would just also have to provide the content type since that is guessed from the file extension.

from aiohttp.

kohtala avatar kohtala commented on September 25, 2024

What's the actual data? Are you opening a file and just want to keep it open? It would not be terribly difficult to allow the constructor to also accept a file object, in particular an instance of BufferedIOBase. The user would just also have to provide the content type since that is guessed from the file extension.

It is not a file at all. It is in-memory generated media data that changes infrequently and has timestamp and content-type from the extension. I like to use the implementation of RFC 7232 and RFC 7233 that is in FileResponse.

from aiohttp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.