Skip to content

Commit

Permalink
private link fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rsjr committed Sep 25, 2024
1 parent 5ab9de3 commit 2dbbea4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cognite/extractorutils/uploader/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
)
Expand All @@ -423,7 +431,7 @@ def _get_file_upload_request(

return Request(
method="PUT",
url=url,
url=upload_url,
stream=IOByteStream(stream),
headers=headers,
)
Expand Down

0 comments on commit 2dbbea4

Please sign in to comment.