Skip to content

Commit 362b9a3

Browse files
committed
Fix Nexus Mods upload: update field names to match current v3 API
The Nexus v3 API renamed multipart upload response fields: - parts_presigned_url -> part_presigned_urls - parts_size -> part_size_bytes
1 parent 0b93bc7 commit 362b9a3

1 file changed

Lines changed: 22 additions & 7 deletions

File tree

release.ps1

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,27 @@ function Upload-ToNexus {
223223
Write-Host "Uploading $fileName ($([math]::Round($fileSize / 1MB, 1)) MB) to group $GroupId..." -ForegroundColor Yellow
224224

225225
# 1. Create multipart upload
226+
# Note: size_bytes sent as string per current Nexus v3 API spec
226227
$upload = Invoke-NexusApi -Method POST -Path "/uploads/multipart" -Body @{
227228
filename = $fileName
228-
size_bytes = $fileSize
229+
size_bytes = "$fileSize"
230+
}
231+
$data = if ($upload.data) { $upload.data } else { $upload }
232+
$uploadId = $data.id
233+
$partUrls = $data.part_presigned_urls
234+
$partSize = $data.part_size_bytes
235+
$completeUrl = $data.complete_presigned_url
236+
237+
if (-not $uploadId) {
238+
Write-Host "ERROR: Nexus API did not return an upload ID. Raw response:" -ForegroundColor Red
239+
Write-Host ($upload | ConvertTo-Json -Depth 5 -Compress) -ForegroundColor Red
240+
exit 1
241+
}
242+
if (-not $partUrls -or $partUrls.Count -eq 0) {
243+
Write-Host "ERROR: Nexus API returned 0 upload parts. Raw response:" -ForegroundColor Red
244+
Write-Host ($upload | ConvertTo-Json -Depth 5 -Compress) -ForegroundColor Red
245+
exit 1
229246
}
230-
$uploadId = $upload.data.id
231-
$partUrls = $upload.data.parts_presigned_url
232-
$partSize = $upload.data.parts_size
233-
$completeUrl = $upload.data.complete_presigned_url
234247

235248
Write-Host " Upload ID: $uploadId ($($partUrls.Count) parts, $([math]::Round($partSize / 1MB, 1)) MB each)"
236249

@@ -284,7 +297,8 @@ function Upload-ToNexus {
284297
$maxAttempts = 60
285298
for ($attempt = 0; $attempt -lt $maxAttempts; $attempt++) {
286299
$status = Invoke-NexusApi -Method GET -Path "/uploads/$uploadId"
287-
$state = $status.data.state
300+
$statusData = if ($status.data) { $status.data } else { $status }
301+
$state = $statusData.state
288302
Write-Host " State: $state"
289303
if ($state -eq "available") { break }
290304
$delay = [math]::Min(2000 * [math]::Pow(1.5, $attempt), 30000)
@@ -303,8 +317,9 @@ function Upload-ToNexus {
303317
version = $Version
304318
file_category = $Category
305319
}
320+
$resultData = if ($result.data) { $result.data } else { $result }
306321

307-
Write-Host " File created: $($result.data.id)" -ForegroundColor Green
322+
Write-Host " File created: $($resultData.id)" -ForegroundColor Green
308323
}
309324

310325
Invoke-Step "Uploading to Nexus Mods" {

0 commit comments

Comments
 (0)