Llo*_*nks 39 powershell amazon-s3 amazon-ec2 powershell-3.0
我使用Powershell的Invoke-WebRequest
方法将文件从Amazon S3下载到我的Windows EC2实例.
如果我使用Chrome下载文件,我可以在5秒内下载200 MB文件.PowerShell使用相同的下载Invoke-WebRequest
最多需要5分钟.
为什么使用Invoke-WebRequest
速度较慢,有没有办法在PowerShell脚本中全速下载?
Tin*_*rus 53
如果不切换Invoke-WebRequest,关闭进度条就可以了.我找到了这个帖子的答案:https://github.com/PowerShell/PowerShell/issues/2138(jasongin于2016年10月3日评论)
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest <params>
Run Code Online (Sandbox Code Playgroud)
对于localhost上的5MB文件,下载时间从30秒到250毫秒.
请注意,要在活动shell中获取进度条,您需要调用$ProgressPreference = 'Continue'
.
Llo*_*nks 27
我在用
Invoke-WebRequest $video_url -OutFile $local_video_url
Run Code Online (Sandbox Code Playgroud)
我改变了以上内容
$wc = New-Object net.webclient
$wc.Downloadfile($video_url, $local_video_url)
Run Code Online (Sandbox Code Playgroud)
这将下载速度恢复到我在浏览器中看到的速度.
小智 10
$ProgressPreference = 'SilentlyContinue'
对于 450 M. 壮观的文件,我将其从 52 分钟缩短到 14 秒。
单行下载文件到临时目录:
(New-Object Net.WebClient).DownloadFile("https://www.google.com", "$env:temp\index.html")
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
14552 次 |
最近记录: |