windows - 如何使多个 Invoke-WebRequest 命令附加到同一个文件?
问题描述
我刚刚开始,所以我一定错过了一些东西。下载每个文件都很好:我只是不知道如何附加到同一个输出文件。这是我目前拥有的。
Invoke-WebRequest -Uri "https://website.com/part1.bin" -OutFile "D:\stuff\bigfile.bin"
Invoke-WebRequest -Uri "https://website.com/part2.bin" -OutFile "D:\stuff\bigfile.bin"
Invoke-WebRequest -Uri "https://website.com/part3.bin" -OutFile "D:\stuff\bigfile.bin"
有小费吗?谢谢。
解决方案
这是我最终使用的。为我工作!
# Requires Powershell 6.0+ because of AsByteStream
# Example array containing URLs to combine
$arrUrls = @('https://website.com/part1.bin','https://website.com/part2.bin','https://website.com/part3.bin')
$tempFile = "temp.bin"
$outputFile = "wholefile.bin"
# For each url, download in a temp file, then append to output file
foreach ($myUrl in $arrUrls)
{
Invoke-WebRequest -Uri $myUrl -OutFile $tempFile
$byteArray = Get-Content $tempFile -AsByteStream -Raw
Add-Content $outputFile -Value $byteArray -AsByteStream
}
推荐阅读
- javascript - 映射具有多个参数的函数
- elixir - 使用 via 元组注册 GenServer 时遇到问题。** (UndefinedFunctionError) 函数 PokerServer.whereis_name/1 未定义或私有)
- python - 您可以在 mpi4py 程序中使用 click 吗?
- python - 抓取多个网址硒
- python - 将罗马转换为整数 - Python
- xcode - 无法在 XCode 13 中连接 IBOutlet
- unity3d - Unity Ragdolls 导致网格渲染器出现问题
- r - R Markdown to PDF导致行溢出页面
- node.js - 如何在我的 React 应用程序中添加社交媒体共享功能?
- css - vscode顺风css智能感知不起作用