I am playing around with Web API and returning octet-stream for file download.
I was just wondering if there is no way to get the filestream when saving the ‘iwr’ in a variable?
This works:
Invoke-WebRequest $url -ContentType “application/json” -OutFile C:\temp\test.txt
But I can’t manage to get the file out if I save the ‘iwr’ in a variable?
$request = Invoke-WebRequest $url -ContentType “application/json”
I like this. Is there an easy way to keep the file in memory instead of writing it to disk? I am using the following directives to download a ZIP file, but I would like to keep the file in memory instead of writing it to disk (just for my own satisfaction).
So instead of Set-Conent writing to disk, it would just output the byte value so I could keep it in a PowerShell variable. Or even, I could pipe the result to
Expand-Archive
so that it writes the contents to disk without ever having the ZIP stored.