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, )