どのように私は、PowerShellを使用して、私のFTPサーバへの2ギガバイト以上のファイルをアップロードすることができ、私は以下の機能には、FTP経由2ギガバイト以上のファイルをアップロードすることはできません - PowerShellの
# Create FTP Rquest Object
$FTPRequest = [System.Net.FtpWebRequest]::Create("$RemoteFile")
$FTPRequest = [System.Net.FtpWebRequest]$FTPRequest
$FTPRequest.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile
$FTPRequest.Credentials = new-object System.Net.NetworkCredential($Username, $Password)
$FTPRequest.UseBinary = $true
$FTPRequest.Timeout = -1
$FTPRequest.KeepAlive = $false
$FTPRequest.ReadWriteTimeout = -1
$FTPRequest.UsePassive = $true
# Read the File for Upload
$FileContent = [System.IO.File]::ReadAllBytes(“$LocalFile”)
$FTPRequest.ContentLength = $FileContent.Length
# Get Stream Request by bytes
try{
$Run = $FTPRequest.GetRequestStream()
$Run.Write($FileContent, 0, $FileContent.Length)
# Cleanup
$Run.Close()
$Run.Dispose()
} catch [System.Exception]{
'Upload failed.'
}
を使用しています私はこのエラーを取得していますアップロード中。
Exception calling "ReadAllBytes" with "1" argument(s): "The file is too long.
This operation is currently limited to supporting files less than 2 gigabytes
in size."
+ $FileContent = [System.IO.File]::ReadAllBytes(“$LocalFile”)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : IOException
私は他の機能を使用しているが、それはチャンクに大きなファイルを分割する以外に、このためのソリューションがある50キロバイト/ sの 希望よりも高いつもりではなかったように結果がとても遅いアップロードの速度だった
可能重複http://stackoverflow.com/質問/ 39345335/powershell-read-file-in-chunks) – sodawillow
私はそれを今すぐチェックします.. – Vagho
'$ FileStream = [System.IO.File] :: OpenRead(" $ LocalFil e "); $ FTPRequest.ContentLength = $ FileStream.Length; $ Run = $ FTPRequest.GetRequestStream(); $ FileStream.CopyTo($ Run); $ Run.Close(); $ FileStream.Close(); ' – PetSerAl