requests-file

File transport adapter for Requests

Apache 2.0 16 个版本
安装
pip install requests-file
poetry add requests-file
pipenv install requests-file
conda install requests-file
描述

Requests-File

Requests-File is a transport adapter for use with the Requests_ Python library to allow local filesystem access via file:// URLs.

To use:

.. code-block:: python

import requests
from requests_file import FileAdapter

s = requests.Session()
s.mount('file://', FileAdapter())

resp = s.get('file:///path/to/file')

Features

  • Will open and read local files
  • Might set a Content-Length header
  • That's about it

No encoding information is set in the response object, so be careful using Response.text: the chardet library will be used to convert the file to a unicode type and it may not detect what you actually want.

EACCES is converted to a 403 status code, and ENOENT is converted to a 404. All other IOError types are converted to a 400.

Contributing

Contributions welcome! Feel free to open a pull request against https://codeberg.org/dashea/requests-file

License

To maximise compatibility with Requests, this code is licensed under the Apache license. See LICENSE for more details.

.. _Requests: https://github.com/psf/requests

版本列表
3.0.1 2025-10-20
3.0.0 2025-10-16
2.1.0 2024-05-21
2.0.0 2024-01-30
1.5.1 2020-04-25
1.5.0 2020-04-24
1.4.3 2018-01-02
1.4.2 2017-04-28
1.4.1 2016-10-13
1.4 2015-08-24
1.3.1 2015-05-18
1.3
1.2 2015-05-08
1.1 2015-03-12
1.0 2015-03-10
0.1