I'm quite new with Python, and I'm trying to find out how to read a remote file without having to download it. Normally, if the file is on my HDD, I just have to do
with open('file.jpg', "rb") as file:
data = file.read()
And then I have a stream of my file.
Now, if the file is located at a http://.../file.jpg I obviously can't use open(). I don't want to download it then open it from hard drive but directly stream it from its original URL. How can I do that? Thank you in advance.
requestsmodule to read from URLs.requests, Python's ownurllib.request.urlopenworks in most simple cases and functions just likeopen()for files, which is convenient.