@@ -178,12 +178,18 @@ def upload(
178178 size = os .path .getsize (file .name )
179179 body : dict [str , t .Any ] = {** kwargs }
180180
181+ use_upload_endpoint = repository is None and self .pulp_ctx .has_plugin (
182+ PluginRequirement ("rpm" , specifier = ">=3.32.5" )
183+ )
184+
181185 if not self .pulp_ctx .fake_mode :
182- if chunk_size > size :
183- # Small file: direct upload
186+ # The "upload" endpoint always requires direct file upload (no chunking)
187+ # The "create" endpoint supports chunked upload for large files
188+ if use_upload_endpoint or chunk_size > size :
189+ # Direct file upload: required for upload endpoint, or small files
184190 body ["file" ] = file
185191 else :
186- # Large file: chunked upload
192+ # Large file with create endpoint : chunked upload
187193 if self .pulp_ctx .has_plugin (PluginRequirement ("core" , specifier = ">=3.20.0" )):
188194 from pulp_glue .core .context import PulpUploadContext
189195
@@ -195,11 +201,8 @@ def upload(
195201 artifact_href = PulpArtifactContext (self .pulp_ctx ).upload (file , chunk_size )
196202 body ["artifact" ] = artifact_href
197203
198- # For rpm plugin >= 3.32.5, use synchronous upload endpoint when no repository is provided
199- # For older versions, always use the create endpoint (backward compatibility)
200- if repository is None and self .pulp_ctx .has_plugin (
201- PluginRequirement ("rpm" , specifier = ">=3.32.5" )
202- ):
204+ # Call the appropriate endpoint
205+ if use_upload_endpoint :
203206 return self .call ("upload" , body = body )
204207
205208 # Repository is specified or older rpm version: use create endpoint (async path)
0 commit comments