question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invoke-RestMethod fails on very large files

See original GitHub issue

It seems Invoke-RestMethod fails to download very large files, probably due to not enough memory.

Steps to reproduce

Invoke-RestMethod -Uri http://speedtest.tele2.net/10GB.zip -OutFile /Users/ffeldhaus/Downloads/10GB.zip

Expected behavior

Very large files should be downloaded without issues.

Actual behavior

PS /Users/ffeldhaus/development> Invoke-RestMethod -Uri http://speedtest.tele2.net/10GB.zip -OutFile /Users/ffeldhaus/Downloads/10GB.zip
Invoke-RestMethod : Stream was too long.
At line:1 char:1
+ Invoke-RestMethod -Uri http://speedtest.tele2.net/10GB.zip -OutFile / ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Invoke-RestMethod], IOException
+ FullyQualifiedErrorId :
System.IO.IOException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand     

Environment data

Mac OS X 10.12.5

PS /Users/ffeldhaus/development> $PSVersionTable                                                                                                                                                                                              

Name                           Value                                                                                                                                                                                                         
----                           -----                                                                                                                                                                                                         
PSVersion                      6.0.0-beta                                                                                                                                                                                                    
PSEdition                      Core                                                                                                                                                                                                          
BuildVersion                   3.0.0.0                                                                                                                                                                                                       
CLRVersion                                                                                                                                                                                                                                   
GitCommitId                    v6.0.0-beta.2                                                                                                                                                                                                 
OS                             Darwin 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64                                                                                                
Platform                       Unix                                                                                                                                                                                                          
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                       
PSRemotingProtocolVersion      2.3                                                                                                                                                                                                           
SerializationVersion           1.1.0.1                                                                                                                                                                                                       
WSManStackVersion              3.0     

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:22 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
iSazonovcommented, Nov 17, 2019

@daxian-dbw Thanks for remainder! It seems BufferingStreamReader class has an issue. Also I discovered that Ctrl-C doesn’t work in Invoke-RestMethod for the large file download scenario. So I pulled a PR to resolve both issues.

1reaction
iSazonovcommented, Nov 15, 2019

I tried 7.0 Preview5 without any issue:

 Invoke-WebRequest -Uri https://images-dl.endlessm.com/release/3.7.3/eos-amd64-amd64/th/eos-eos3.7-amd64-amd64.191024-140039.th.iso -OutFile C:\temp\q.txt

It was 9.4 Gb and was long but no memory issues and no exceptions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Having trouble uploading large files with Invoke-RestMethod
I am trying to use the Hashicorp Atlas restful api to upload box files into but I am running into problems when uploading...
Read more >
windows server 2012 r2 - Download big files with PowerShell
Invoke -WebRequest was designed for small files and it's speed is very slow. Note that BITS can show progress, because Write-Progress cmdlet can ......
Read more >
Invoke-WebRequest large file upload - underlying ...
I'm trying to upload a large file to Nexus repo using Invoke-WebRequest and getting the following error message.
Read more >
Invoke-RestMethod - PowerShell
The Invoke-RestMethod cmdlet sends HTTP and HTTPS requests to Representational State Transfer (REST) web services that return richly structured data.
Read more >
Invoke-RestMethod fails when the powershell is run from ...
Hi, I have a developer who has a working Invoke-RestMethod when its run from any other server but fails when its run from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found