I want to upload a file via HTTP using urllib3 . I managed to do this using the following code:
url = 'http://url_to_a_file' connection_pool = urllib3.PoolManager() resp = connection_pool.request('GET',url ) f = open(filename, 'wb') f.write(resp.data) f.close() resp.release_conn()
But I was wondering what the right way to do this is. For example, it will work well for large files, and if not, what to do to make this code more error resistant and scalable.
Note. It is important for me to use the urllib3 not urllib2 , for example, because I want my code to be thread safe.
source share