# Minimal direct upload (no size check) - fast overwrite upload $FtpHost="116.198.221.125"; $FtpUser="wenchuanyi"; $FtpPass="r7P^f*v7rFts" $Stage = Join-Path $env:TEMP "wcy_publish_staging" $Log = "D:\CodeBuddy\Pros\WenChuanyi\deploy\ftp_fast.log" Set-Content -Path $Log -Value "start $(Get-Date -Format HH:mm:ss)" -Encoding UTF8 function L([string]$m){ Add-Content -Path $Log -Value $m -Encoding UTF8 } function NewR($p,$m){ $r=[System.Net.FtpWebRequest]::Create("ftp://${FtpHost}/$p"); $r.Method=$m; $r.Credentials=New-Object System.Net.NetworkCredential($FtpUser,$FtpPass); $r.UsePassive=$true; $r.UseBinary=$true; $r.KeepAlive=$false; $r.Timeout=120000; $r } function Mk($p){ $r=NewR $p ([System.Net.WebRequestMethods+Ftp]::MakeDirectory); try{$null=$r.GetResponse()}catch{} } function Put($lp,$rp){ for($i=1;$i -le 3;$i++){ try{ $r=NewR $rp ([System.Net.WebRequestMethods+Ftp]::UploadFile) $b=[IO.File]::ReadAllBytes($lp) $r.ContentLength=$b.Length $s=$r.GetRequestStream(); $s.Write($b,0,$b.Length); $s.Close() $x=$r.GetResponse(); $x.Close() L "OK $rp"; return }catch{ L "RETRY($i) $rp : $($_.Exception.Message)"; Start-Sleep 3 } } L "FAIL $rp" } function Up($ld,$rd){ foreach($d in Get-ChildItem $ld -Directory){ # skip Kerberos native dir - rejected by server, not needed on Windows if($d.FullName -match "win-x64[\\/]native$"){ L "SKIPDIR $($d.FullName)"; continue } $c="$rd/$($d.Name)"; Mk $c; Up $d.FullName $c } foreach($f in Get-ChildItem $ld -File){ Put $f.FullName "$rd/$($f.Name)" } } Up $Stage "/wwwroot" L "DONE $(Get-Date -Format HH:mm:ss)"