HTTPBackend¶
- class mmengine.fileio.HTTPBackend[source]¶
HTTP and HTTPS storage bachend.
- get(filepath)[source]¶
Read bytes from a given
filepath
.Examples
>>> backend = HTTPBackend() >>> backend.get('http://path/of/file') b'hello world'
- get_local_path(filepath)[source]¶
Download a file from
filepath
to a local temporary directory, and return the temporary path.get_local_path
is decorated bycontxtlib.contextmanager()
. It can be called withwith
statement, and when exists from thewith
statement, the temporary path will be released.- Parameters:
filepath (str) – Download a file from
filepath
.- Yields:
Iterable[str] – Only yield one temporary path.
- Return type:
Examples
>>> 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