Suppose your server supports range requests . You request the server by the Range header with the start byte and the end byte of the range you want:
import urllib2 req = urllib2.Request(url) req.headers['Range'] = 'bytes=%s-%s' % (startByte, endByte) f = urllib2.urlopen(req) f.read()
You can implement the file object and always download only the necessary fragment of the file from the server. Almost every library accepts an input file as an object.
It will probably be slow due to network latency. You will need to upload large fragments of the file, preload the file into a separate stream, etc. In other words, you will need to implement the logic of the streaming client yourself.
source share