From 82c90d3edc27811a39c33560a6a09016182b1c65 Mon Sep 17 00:00:00 2001 From: ashish-spext Date: Tue, 10 Sep 2024 18:09:35 +0530 Subject: [PATCH 1/2] Added multipart form on local file upload for efficient RAM usage on large files --- requirements.txt | 5 +++-- setup.py | 1 + videodb/_upload.py | 11 +++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/requirements.txt b/requirements.txt index 1159ddd..52e25d6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ -requests==2.31.0 backoff==2.2.1 -tqdm==4.66.1 +requests==2.31.0 +requests-toolbelt==1.0.0 +tqdm==4.66.1 \ No newline at end of file diff --git a/setup.py b/setup.py index db2f955..dc08019 100644 --- a/setup.py +++ b/setup.py @@ -34,6 +34,7 @@ "requests>=2.25.1", "backoff>=2.2.1", "tqdm>=4.66.1", + "requests-toolbelt==1.0.0", ], classifiers=[ "Intended Audience :: Developers", diff --git a/videodb/_upload.py b/videodb/_upload.py index 90f7b46..33212c6 100644 --- a/videodb/_upload.py +++ b/videodb/_upload.py @@ -2,7 +2,7 @@ from typing import Optional from requests import HTTPError - +from requests_toolbelt.multipart.encoder import MultipartEncoder from videodb._constants import ( ApiPath, @@ -36,9 +36,12 @@ def upload( ) upload_url = upload_url_data.get("upload_url") with open(file_path, "rb") as file: - files = {"file": (name, file)} - response = requests.post(upload_url, files=files) - response.raise_for_status() + encoder = MultipartEncoder(fields={"file": (name, file)}) + headers = {"Content-Type": encoder.content_type} + with requests.post( + upload_url, data=encoder, headers=headers + ) as response: + response.raise_for_status() url = upload_url except FileNotFoundError as e: From 0500ba8ddd472cd1cbc814993cdc8ba4030a9628 Mon Sep 17 00:00:00 2001 From: ashish-spext Date: Tue, 10 Sep 2024 18:26:25 +0530 Subject: [PATCH 2/2] Added validation for scene_index_id in get_scene_index --- videodb/video.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/videodb/video.py b/videodb/video.py index e006a39..2102d1f 100644 --- a/videodb/video.py +++ b/videodb/video.py @@ -329,6 +329,8 @@ def list_scene_index(self) -> List: return index_data.get("scene_indexes", []) def get_scene_index(self, scene_index_id: str) -> Optional[List]: + if not scene_index_id: + raise ValueError("scene_index_id is required") index_data = self._connection.get( path=f"{ApiPath.video}/{self.id}/{ApiPath.index}/{ApiPath.scene}/{scene_index_id}" ) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy