HTTPBackend¶
- class mmengine.fileio.HTTPBackend[源代码]¶
HTTP and HTTPS storage bachend.
- get(filepath)[源代码]¶
Read bytes from a given
filepath.示例
>>> backend = HTTPBackend() >>> backend.get('http://path/of/file') b'hello world'
- get_local_path(filepath)[源代码]¶
Download a file from
filepathto a local temporary directory, and return the temporary path.get_local_pathis decorated bycontxtlib.contextmanager(). It can be called withwithstatement, and when exists from thewithstatement, the temporary path will be released.- 参数:
filepath (str) – Download a file from
filepath.- 生成器:
Iterable[str] – Only yield one temporary path.
- 返回类型:
示例
>>> backend = HTTPBackend() >>> # After existing from the ``with`` clause, >>> # the path will be removed >>> with backend.get_local_path('http://path/of/file') as path: ... # do something here