Skip to main content

Ranged read file access abstraction.

Project description

Net-file ranged read file access abstraction library

net-file allows you to access files by URL the same way for different types of storage:

  • local files
  • files served by http(s) servers like Nginx
  • files on SFTP
  • ...

Second major feature of net-file is ranged access. So you can download only part of file starting from arbitrary position.

API

    open_url(
        url: str,                   # File URL. For local file use file:///absolute/file/path
        start_bytes: int = None,    # For ranged access - the beginning of the range
        length: int = None          # For ranged access - range length
    ) -> NetFile

Opens URL returning NetFile object. To read from file use context manager or open() / close() methods pair of NetFile object:

    with open_url(
            url='http://test.domain/example.mp4',
            start_bytes=10000,
            length=20000,
    ) as open_file:
        content = open_file.read()
        while content:
            content = open_file.read()

Speech Technology Center

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

net-file-1.1.6.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

net_file-1.1.6-py3-none-any.whl (8.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page