SHOW:
|
|
- or go back to the newest paste.
| 1 | $user = "admin" | |
| 2 | $pass = "admin123" | |
| 3 | $pair = "${user}:${pass}"
| |
| 4 | ||
| 5 | $fileName = "0.iso"; | |
| 6 | $sourceFilePath = "C:\\$fileName"; | |
| 7 | ||
| 8 | $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) | |
| 9 | $base64 = [System.Convert]::ToBase64String($bytes) | |
| 10 | $basicAuthValue = "Basic $base64" | |
| 11 | ||
| 12 | #$headers = @{ Authorization = $basicAuthValue; "Content-Length" = $sourceFilePath.Length } #Err You must write ContentLength bytes to the request stream before calling [Begin]GetResponse.
| |
| 13 | $headers = @{ Authorization = $basicAuthValue }
| |
| 14 | $uri = "http://nexus.lab.local:8081/nexus/content/sites/myproj/0.iso" | |
| 15 | ||
| 16 | $output = Invoke-WebRequest -Uri $uri -Headers $headers -Method Post -InFile $sourceFilePath -ContentType "multipart/form-data" -TimeoutSec 36000 -Verbose -Debug | |
| 17 | $Error[0].InvocationInfo.Line | |
| 18 | $output | |
| 19 | Write-Host "###################################" | |
| 20 | $Error[0] |