Centos Linux on vmware - gsutil is working but I am trying to download objects from google cloud storage using python code. Running below python code fails as I am behind a prox
Although, google-cloud python library does not have support for proxies directly, it honors HTTPS_PROXY
environment variable if set.
Either:
export HTTPS_PROXY=https://mycustomproxy.example.com:12345
python your_python_script.py
Or:
export https_proxy=https://mycustomproxy.example.com:12345
python your_python_script.py
You could also set this directly within your python script too (preferably at the very beginning):
import os
os.environ['https_proxy'] = 'https://mycustomproxy.example.com:12345'
from google.cloud import storage
storage_client = storage.Client()
bucket = storage_client.get_bucket('my-bucket')
blobs=bucket.list_blobs()
BTW, https_proxy
is supported in the urllib
module and hence any libraries (like google-cloud
here) using urllib
can transparently use the proxies for the requests.