AnswerBun.com

Resume uploading with built-in Windows FTP client

Is it possible to resume uploading with built-in Windows FTP client after FTP client failure/disconnection from previous point?

For example, how to achieve following scenario: build-in FTP client uploads 40% of file, connection was lost, client reconnects and starts uploading of the rest 60% of file? Other FTP clients capable to do this but I restricted by using only software available just after Windows installation.

Super User Asked by Vlad Novakovsky on December 29, 2020

1 Answers

One Answer

No, the Windows command-line ftp.exe does not support transfer resuming.


But you can just automatically download any small 3rd party portable command-line FTP client that supports automatic resume and use that.

For example the following PowerShell code downloads WinSCP .NET assembly package, extracts it and starts a resumable upload:

$winscp_assembly = "WinSCPnet.dll"
if (Test-Path $winscp_assembly)
{
    Write-Host "WinSCP already downloaded"
}
else
{
    $webclient = New-Object System.Net.WebClient
    $winscp_version = "5.17.9"
    $winscp_archive = "WinSCP-$winscp_version-Automation.zip"
    Write-Host "Downloading $winscp_archive ..."
    $url =
        "https://sourceforge.net/projects/winscp/files/WinSCP/" +
        $winscp_version + "/" + $winscp_archive + "/download"
    $webclient.DownloadFile($url, $winscp_archive)
    Write-Host "Done"

    Write-Host "Extracting $winscp_archive ..."
    $shell = New-Object -ComObject Shell.Application    

    $current_path = [string](Resolve-Path ".")
    $winscp_archive_path = [string](Resolve-Path $winscp_archive)
    $winscp_archive_folder = $shell.NameSpace($winscp_archive_path)
    $current_folder = $shell.NameSpace($current_path)
    $copy_options = 4 -bor 16 # SHCONTCH_NOPROGRESSBOX or SHCONTCH_RESPONDYESTOALL
    $current_folder.CopyHere($winscp_archive_folder.Items(), $copy_options)
    Write-Host "Done"
}

Add-Type -Path $winscp_assembly

$ftp_host = "ftp.example.com"
$ftp_path = "/target/path/"
$upload_path = "C:bigfile.dat"
Write-Host "Starting resumable upload of $upload_path to $ftp_host ..."
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Ftp
    HostName = $ftp_host
    UserName = "username"
    Password = "password"
}

$session = New-Object WinSCP.Session
$session.Open($sessionOptions)

$session.PutFiles($upload_path, $ftp_path).Check()

To run the PowerShell script (upload.ps1) use:

powershell.exe -File upload.ps1 -ExecutionPolicy Bypass

(I'm the author of WinSCP)


Another option is to implement the resume manually using FtpWebRequest.

See How to continue or resume FTP upload after interruption of internet.

Again you can use the FtpWebRequest from a PowerShell script. See Upload files with FTP using PowerShell.

Correct answer by Martin Prikryl on December 29, 2020

Add your own answers!

Related Questions

Testing LAN network speed

1  Asked on October 22, 2020 by pablo

       

Vnc viewer authentication failure

1  Asked on October 22, 2020 by twosingleton

 

How To Enable USB Keyboard and Mouse on Boots in HP Prodesk 400 G3

2  Asked on October 21, 2020 by carl-angelo-nievarez

     

RemoteFX Warning

0  Asked on October 18, 2020 by tiago-martins-peres

   

How to control PC from Google smart home?

0  Asked on October 15, 2020 by fuxi

 

Cannot format or change disk properties

0  Asked on October 14, 2020 by gabriel-ziegler

     

cannot remove auto fill entries in Chrome

4  Asked on October 14, 2020 by dimitris-papageorgiou

 

Pixelating webcam data during livestream

1  Asked on October 11, 2020

 

Cannot share screen on Zoom in Ubuntu 17.10

5  Asked on October 9, 2020 by dina

   

Batch that create a batch that create dummy zip file

0  Asked on October 9, 2020 by moreno

 

Can I make this PowerShell Script accept commas?

1  Asked on October 8, 2020 by mark-deven

   

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved.