how can i upload files larger than 2 gb to my FTP server using powershell, i am using the below function
# 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.'
}
i am getting this error while uploading.
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
i have used other functions but the result was so slow upload speed like it was not going higher than 50KB/s hope there is a solution for this, other than splitting the large files into chunks