Skip to content

Commit

Permalink
Merge pull request #54 from jwhitlock/python-public-host
Browse files Browse the repository at this point in the history
Python example - set the public host
  • Loading branch information
fsouza authored Aug 7, 2019
2 parents 88a45a7 + 97d29ee commit 665a60f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions examples/python/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@
from google.auth.credentials import AnonymousCredentials
from google.cloud import storage

BASE_URL = "https://127.0.0.1:4443"
EXTERNAL_URL = "https://127.0.0.1:4443"
PUBLIC_HOST = "storage.gcs.127.0.0.1.nip.io:4443"

storage._http.Connection.API_BASE_URL = (
BASE_URL
) # override the BASE_URL in the client library with the mock server
EXTERNAL_URL
) # override the API_BASE_URL in the client library with the mock server
storage.blob._API_ACCESS_ENDPOINT = "https://" + PUBLIC_HOST
storage.blob._DOWNLOAD_URL_TEMPLATE = (
u"%s/download/storage/v1{path}?alt=media" % BASE_URL
u"%s/download/storage/v1{path}?alt=media" % EXTERNAL_URL
)
storage.blob._BASE_UPLOAD_TEMPLATE = (
u"%s/upload/storage/v1{bucket_path}/o?uploadType=" % BASE_URL
u"%s/upload/storage/v1{bucket_path}/o?uploadType=" % EXTERNAL_URL
)
storage.blob._MULTIPART_URL_TEMPLATE = storage.blob._BASE_UPLOAD_TEMPLATE + u"multipart"
storage.blob._RESUMABLE_URL_TEMPLATE = storage.blob._BASE_UPLOAD_TEMPLATE + u"resumable"
Expand Down

0 comments on commit 665a60f

Please sign in to comment.