|
60 | 60 | from google.cloud.storage._signing import generate_signed_url_v2 |
61 | 61 | from google.cloud.storage._signing import generate_signed_url_v4 |
62 | 62 | from google.cloud.storage._helpers import _NUM_RETRIES_MESSAGE |
| 63 | +from google.cloud.storage._helpers import _DEFAULT_STORAGE_HOST |
| 64 | +from google.cloud.storage._helpers import _API_VERSION |
63 | 65 | from google.cloud.storage.acl import ACL |
64 | 66 | from google.cloud.storage.acl import ObjectACL |
65 | 67 | from google.cloud.storage.constants import _DEFAULT_TIMEOUT |
|
78 | 80 | from google.cloud.storage.fileio import BlobWriter |
79 | 81 |
|
80 | 82 |
|
81 | | -_API_ACCESS_ENDPOINT = "https://storage.googleapis.com" |
| 83 | +_API_ACCESS_ENDPOINT = _DEFAULT_STORAGE_HOST |
82 | 84 | _DEFAULT_CONTENT_TYPE = "application/octet-stream" |
83 | | -_DOWNLOAD_URL_TEMPLATE = "{hostname}/download/storage/v1{path}?alt=media" |
84 | | -_BASE_UPLOAD_TEMPLATE = "{hostname}/upload/storage/v1{bucket_path}/o?uploadType=" |
| 85 | +_DOWNLOAD_URL_TEMPLATE = "{hostname}/download/storage/{api_version}{path}?alt=media" |
| 86 | +_BASE_UPLOAD_TEMPLATE = ( |
| 87 | + "{hostname}/upload/storage/{api_version}{bucket_path}/o?uploadType=" |
| 88 | +) |
85 | 89 | _MULTIPART_URL_TEMPLATE = _BASE_UPLOAD_TEMPLATE + "multipart" |
86 | 90 | _RESUMABLE_URL_TEMPLATE = _BASE_UPLOAD_TEMPLATE + "resumable" |
87 | 91 | # NOTE: "acl" is also writeable but we defer ACL management to |
@@ -823,7 +827,9 @@ def _get_download_url( |
823 | 827 | name_value_pairs = [] |
824 | 828 | if self.media_link is None: |
825 | 829 | hostname = _get_host_name(client._connection) |
826 | | - base_url = _DOWNLOAD_URL_TEMPLATE.format(hostname=hostname, path=self.path) |
| 830 | + base_url = _DOWNLOAD_URL_TEMPLATE.format( |
| 831 | + hostname=hostname, path=self.path, api_version=_API_VERSION |
| 832 | + ) |
827 | 833 | if self.generation is not None: |
828 | 834 | name_value_pairs.append(("generation", f"{self.generation:d}")) |
829 | 835 | else: |
@@ -1838,7 +1844,7 @@ def _do_multipart_upload( |
1838 | 1844 |
|
1839 | 1845 | hostname = _get_host_name(client._connection) |
1840 | 1846 | base_url = _MULTIPART_URL_TEMPLATE.format( |
1841 | | - hostname=hostname, bucket_path=self.bucket.path |
| 1847 | + hostname=hostname, bucket_path=self.bucket.path, api_version=_API_VERSION |
1842 | 1848 | ) |
1843 | 1849 | name_value_pairs = [] |
1844 | 1850 |
|
@@ -2025,7 +2031,7 @@ def _initiate_resumable_upload( |
2025 | 2031 |
|
2026 | 2032 | hostname = _get_host_name(client._connection) |
2027 | 2033 | base_url = _RESUMABLE_URL_TEMPLATE.format( |
2028 | | - hostname=hostname, bucket_path=self.bucket.path |
| 2034 | + hostname=hostname, bucket_path=self.bucket.path, api_version=_API_VERSION |
2029 | 2035 | ) |
2030 | 2036 | name_value_pairs = [] |
2031 | 2037 |
|
|
0 commit comments