File class is a "virtual file" with many of the same methods as the
built-in Python file object. It inherits from Python's
class, which means there are familiar methods like
close(). However, because the File class is backed by Edge's storage
system, there are some differences:
Fileobjects are not writeable. This is a limitation of the underlying object store.
- Reading from a
- They are seekable, but there is high latency associated with this operation as a new HTTP request needs to be sent. For best efficiency, you should do contiguous reads.
- We provide a couple of additional properties and methods:
You can use File objects as a context manager, ensuring they are automatically closed:
mysession = EdgeSession()
with mysession.files.open('myfile') as f:
data = f.read()
Property (str). The name (not full path) of the file on Edge.
Property (int). Size of the file, in bytes.
download_url() -> str
Get a signed HTTPS url which can be used to fetch the file. Useful when it's necessary to download a file outside of the Edge API. For example, you can generate a link and pass it to a user's brower, so they can download the file directly to their computer.