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:
$winscpAssembly = "WinSCPnet.dll"
if (Test-Path $winscpAssembly)
{
Write-Host "WinSCP already downloaded"
}
else
{
$bestReleaseUrl = "https://sourceforge.net/projects/winscp/best_release.json"
$winscpBestRelease = Invoke-WebRequest $bestReleaseUrl | ConvertFrom-Json
$url = $winscpBestRelease.release.url
$url = $url -replace "-Setup.exe", "-Automation.zip"
Write-Host "Downloading ..."
$winscpArchive = "WinSCP-Automation.zip"
$webclient = New-Object System.Net.WebClient
$webclient.DownloadFile($url, $winscpArchive)
Write-Host "Done"
Write-Host "Extracting $winscpArchive ..."
Expand-Archive $winscpArchive .
Write-Host "Done"
}
Add-Type -Path $winscpAssembly
$ftp_host = "ftp.example.com"
$ftp_path = "/target/path/"
$upload_path = "C:\big\file.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
The script uses PowerShell 5 Expand-Archive
cmdlet. If you need to use older version of PowerShell, check an old revision of this answer for a solution with use of Shell.Application
object.
(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.