I’m trying to upload a large file to Nexus repo using Invoke-WebRequest and getting the following error message.
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$publishUrl = "https://nexusurl/dd.zip"
$filePath = "C:\TEMP\mvp.zip"
$Username = "admin"
$Password = "adminpass"
$params = @{
UseBasicParsing = $true
Uri = $publishUrl
Method = "POST"
InFile = $filePath
Headers = @{
ContentType = "application/zip"
Authorization = "Basic $([System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("$Username`:$Password")))"
}
}
Invoke-WebRequest @params -TimeoutSec 3600
It seems like uploading 1-2gig file works fine but anything larger than that, Im getting the error.
same question is posted in powershell - Invoke-WebRequest large file upload - underlying connection was closed - Stack Overflow