我正在尝试使用PowerShell上传大型备份文件(~1-2GB)。我正在使用HTTP Post尝试放置文件但是收到此错误:
Invoke-RestMethod : The underlying connection was closed: An unexpected error occurred on a send.
At C:\Repository\Powershell\PS-LaptopBackup\OneDrive Upload\main.ps1:61 char:71
+ $bak_files | foreach-object { Write-Host "UPLOADING: $($_.Name)"; Invoke-Res ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
我用来上传的命令是
Invoke-RestMethod -Uri "$($upload_location)/$($_.Name)`?access_token=$AccessToken" -Method Put -InFile $_.FullName -TimeoutSec 3600
该命令有效,但会抛出该错误。我认为这是因为HTTP连接失败。还有另一种与OneDrive交互的方式吗?
谢谢, 纳特
答案 0 :(得分:0)
您可以尝试使用POST而不是PUT,因为我找到了api文档: http://msdn.microsoft.com/en-us/library/dn659726.aspx#download_a_file
如果你能解决这个问题,请在这里发布解决方案吗?