Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

WebClient.UploadFile Slow upload speed

$
0
0

hey guys, i am using the below function, to upload files to my ftp server, and its uploading with a speed not exceeding 49KB/s

but when uploading the same file using filezilla ftp client the speed is over 400KB/s

Function Get-Webclient ($url, $Path, $usrName, $passwd) {

    $proxy = [System.Net.WebRequest]::GetSystemWebProxy()
    $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
    $request = New-Object System.Net.WebCLient
    $request.UseDefaultCredentials = $true
    $request.Proxy.Credentials = $request.Credentials
    $securedPasswd = ConvertTo-SecureString $passwd -AsPlainText -Force
    $request.Credentials = New-Object System.Management.Automation.PSCredential ($usrName, $securedPasswd)

    Write-Host "Uploading files to :  $url"

    Get-ChildItem -Path $Path -File | % {
        $CompleteDPath = $url + $($_.Name)

        Write-Host "Uploading :  $($_.Name)"
        $request.UploadFile($CompleteDPath, "STOR", $($_.FullName))
    }
}

i checked the logs on the FTP server, 

Logs when uploading by PowerShell

(000014)1/13/2017 1:23:45 AM - (not logged in) (x.x.x.x)> Connected on port 50005, sending welcome message...
(000014)1/13/2017 1:23:45 AM - (not logged in) (x.x.x.x)> 220-FileZilla Server 0.9.55 beta
(000014)1/13/2017 1:23:45 AM - (not logged in) (x.x.x.x)> 220-written by Tim Kosse (tim.kosse@filezilla-project.org)
(000014)1/13/2017 1:23:45 AM - (not logged in) (x.x.x.x)> 220 Please visit https://filezilla-project.org/
(000014)1/13/2017 1:23:45 AM - (not logged in) (x.x.x.x)> USER user
(000014)1/13/2017 1:23:45 AM - (not logged in) (x.x.x.x)> 331 Password required for user
(000014)1/13/2017 1:23:45 AM - (not logged in) (x.x.x.x)> PASS ***********
(000014)1/13/2017 1:23:45 AM - user (x.x.x.x)> 230 Logged on
(000014)1/13/2017 1:23:46 AM - user (x.x.x.x)> OPTS utf8 on
(000014)1/13/2017 1:23:46 AM - user (x.x.x.x)> 202 UTF8 mode is always enabled. No need to send this command.
(000014)1/13/2017 1:23:46 AM - user (x.x.x.x)> PWD
(000014)1/13/2017 1:23:46 AM - user (x.x.x.x)> 257 "/" is current directory.
(000014)1/13/2017 1:23:46 AM - user (x.x.x.x)> TYPE I
(000014)1/13/2017 1:23:46 AM - user (x.x.x.x)> 200 Type set to I
(000014)1/13/2017 1:23:47 AM - user (x.x.x.x)> PASV
(000014)1/13/2017 1:23:47 AM - user (x.x.x.x)> 227 Entering Passive Mode (52,42,201,99,195,84)
(000014)1/13/2017 1:23:47 AM - user (x.x.x.x)> STOR test1/test.zip
(000014)1/13/2017 1:23:47 AM - user (x.x.x.x)> 150 Opening data channel for file upload to server of "/test1/test.zip"

Logs when uploading by FileZilla FTP Client

(000012)1/13/2017 1:22:01 AM - (not logged in) (x.x.x.x)> Connected on port 50005, sending welcome message...
(000012)1/13/2017 1:22:01 AM - (not logged in) (x.x.x.x)> 220-FileZilla Server 0.9.55 beta
(000012)1/13/2017 1:22:01 AM - (not logged in) (x.x.x.x)> 220-written by Tim Kosse (tim.kosse@filezilla-project.org)
(000012)1/13/2017 1:22:01 AM - (not logged in) (x.x.x.x)> 220 Please visit https://filezilla-project.org/
(000012)1/13/2017 1:22:01 AM - (not logged in) (x.x.x.x)> AUTH TLS
(000012)1/13/2017 1:22:01 AM - (not logged in) (x.x.x.x)> 502 Explicit TLS authentication not allowed
(000012)1/13/2017 1:22:02 AM - (not logged in) (x.x.x.x)> AUTH SSL
(000012)1/13/2017 1:22:02 AM - (not logged in) (x.x.x.x)> 502 Explicit TLS authentication not allowed
(000012)1/13/2017 1:22:02 AM - (not logged in) (x.x.x.x)> USER user
(000012)1/13/2017 1:22:02 AM - (not logged in) (x.x.x.x)> 331 Password required for user
(000012)1/13/2017 1:22:02 AM - (not logged in) (x.x.x.x)> PASS ***********
(000012)1/13/2017 1:22:02 AM - user (x.x.x.x)> 230 Logged on
(000012)1/13/2017 1:22:03 AM - user (x.x.x.x)> CWD /test1
(000012)1/13/2017 1:22:03 AM - user (x.x.x.x)> 250 CWD successful. "/test1" is current directory.
(000012)1/13/2017 1:22:03 AM - user (x.x.x.x)> TYPE I
(000012)1/13/2017 1:22:03 AM - user (x.x.x.x)> 200 Type set to I
(000012)1/13/2017 1:22:03 AM - user (x.x.x.x)> PASV
(000012)1/13/2017 1:22:03 AM - user (x.x.x.x)> 227 Entering Passive Mode (52,42,201,99,195,84)
(000012)1/13/2017 1:22:04 AM - user (x.x.x.x)> STOR test.zip
(000012)1/13/2017 1:22:04 AM - user (x.x.x.x)> 150 Opening data channel for file upload to server of "/test1/test.zip"
can any one tell me what could be the reason that with PowerShell the speed is very slow ?


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>