From c126cb10c72d406bf413e640a5069de5e38c4409 Mon Sep 17 00:00:00 2001 From: Alexander Reynolds Date: Wed, 4 Sep 2024 21:33:39 -0400 Subject: [PATCH 1/2] missed the urlsafe escape on the add_to_dataset method --- nominal/sdk.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nominal/sdk.py b/nominal/sdk.py index 0c73b87b..457692b1 100644 --- a/nominal/sdk.py +++ b/nominal/sdk.py @@ -229,8 +229,8 @@ def add_to_dataset_from_io( raise TypeError(f"dataset {dataset} must be open in binary mode, rather than text mode") self.poll_until_ingestion_completed() - - filename = f"{self.name}{file_extension}" + urlsafe_name = urlsafe_b64encode(self.name.encode()).decode() + filename = f"{urlsafe_name}{file_extension}" s3_path = put_multipart_upload( self._client._auth_header, dataset, filename, "text/csv", self._client._upload_client ) From dd5dcc9cee1920723ad2c4f7d3d9f9ea4cafe4c8 Mon Sep 17 00:00:00 2001 From: Alexander Reynolds Date: Wed, 4 Sep 2024 21:36:54 -0400 Subject: [PATCH 2/2] use urllib.parse rather than b64 --- nominal/sdk.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nominal/sdk.py b/nominal/sdk.py index 457692b1..8d5275b0 100644 --- a/nominal/sdk.py +++ b/nominal/sdk.py @@ -1,7 +1,7 @@ from __future__ import annotations import time -from base64 import urlsafe_b64encode +import urllib.parse from dataclasses import dataclass, field from datetime import datetime, timedelta from io import TextIOBase @@ -229,7 +229,7 @@ def add_to_dataset_from_io( raise TypeError(f"dataset {dataset} must be open in binary mode, rather than text mode") self.poll_until_ingestion_completed() - urlsafe_name = urlsafe_b64encode(self.name.encode()).decode() + urlsafe_name = urllib.parse.quote_plus(self.name) filename = f"{urlsafe_name}{file_extension}" s3_path = put_multipart_upload( self._client._auth_header, dataset, filename, "text/csv", self._client._upload_client @@ -463,7 +463,7 @@ def create_dataset_from_io( if isinstance(dataset, TextIOBase): raise TypeError(f"dataset {dataset} must be open in binary mode, rather than text mode") - urlsafe_name = urlsafe_b64encode(name.encode()).decode() + urlsafe_name = urllib.parse.quote_plus(name) filename = f"{urlsafe_name}{file_extension}" s3_path = put_multipart_upload(self._auth_header, dataset, filename, "text/csv", self._upload_client) request = ingest_api.TriggerFileIngest( @@ -531,7 +531,7 @@ def create_attachment_from_io( """ # TODO(alkasm): create attachment from file/path - urlsafe_name = urlsafe_b64encode(title.encode()).decode() + urlsafe_name = urllib.parse.quote_plus(title) if isinstance(attachment, TextIOBase): raise TypeError(f"attachment {attachment} must be open in binary mode, rather than text mode") s3_path = put_multipart_upload(self._auth_header, attachment, urlsafe_name, mimetype, self._upload_client)