From 2dbbea494ae2ab677749c0de078dcd5d6f784c3f Mon Sep 17 00:00:00 2001 From: Rogerio Junior Date: Wed, 25 Sep 2024 09:22:02 +0200 Subject: [PATCH] private link fix --- cognite/extractorutils/uploader/files.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cognite/extractorutils/uploader/files.py b/cognite/extractorutils/uploader/files.py index 62349d7a..b1569f76 100644 --- a/cognite/extractorutils/uploader/files.py +++ b/cognite/extractorutils/uploader/files.py @@ -408,12 +408,20 @@ def _get_file_upload_request( self, url_str: str, stream: BinaryIO, size: int, mime_type: Optional[str] = None ) -> Request: url = URL(url_str) + base_url = URL(self.cdf_client.config.base_url) + + # same logic as the SDK + if url.netloc: + upload_url = url + else: + upload_url = URL.join(base_url, url) + headers = Headers(self._httpx_client.headers) headers.update( { "Accept": "*/*", "Content-Length": str(size), - "Host": url.netloc.decode("ascii"), + "Host": upload_url.netloc.decode("ascii"), "x-cdp-app": self.cdf_client._config.client_name, } ) @@ -423,7 +431,7 @@ def _get_file_upload_request( return Request( method="PUT", - url=url, + url=upload_url, stream=IOByteStream(stream), headers=headers, )