From 1ea67d539dacda4ebd47927a30a8a502dbe2993a Mon Sep 17 00:00:00 2001 From: Siddhant Goel Date: Wed, 6 Nov 2024 17:15:06 +0100 Subject: [PATCH] chore: fix broken test --- streaming_form_data/targets.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/streaming_form_data/targets.py b/streaming_form_data/targets.py index 6c2bd66..6c88985 100644 --- a/streaming_form_data/targets.py +++ b/streaming_form_data/targets.py @@ -71,9 +71,19 @@ def __init__(self, next_target: Callable): self._targets = [] self._validator = None # next_target should have a validator + self._next_multipart_filename = None + self._next_multipart_content_type = None + def on_start(self): target = self._next_target() + if self._next_multipart_filename is not None: + target.set_multipart_filename(self._next_multipart_filename) + self._next_multipart_filename = None + if self._next_multipart_content_type is not None: + target.set_multipart_filename(self._next_multipart_content_type) + self._next_multipart_content_type = None + self._targets.append(target) target.start() @@ -84,10 +94,10 @@ def on_finish(self): self._targets[-1].finish() def set_multipart_filename(self, filename: str): - self._targets[-1].set_multipart_filename(filename) + self._next_multipart_filename = filename def set_multipart_content_type(self, content_type: str): - self._targets[-1].set_multipart_content_type(content_type) + self._next_multipart_content_type = content_type class NullTarget(BaseTarget):