This is an old revision of the document!

put

Uploads one or more files from local directory to remote directory.

Advertisement

Examples

put index.html
put -delete index.html about.html ./
put -permissions=644 index.html about.html /home/martin/public_html/
put d:\www\index.html about.*
put *.html *.png /home/martin/backup/*.bak
put -filemask=*.html -resumesupport=on *

Converting to .NET Assembly

When converting script to .NET Assembly, map put command to Session.PutFiles method.

Parameters mapping: Command parameter file maps to method parameter localPath. When multiple source file parameters are used, you need to call Session.PutFiles multiple times. Command parameter directory/newname maps to method parameter remotePath. You have to convert relative paths to absolute paths.

Advertisement

Switches mapping:

Switch Mapping
-delete Value true ($True in PowerShell) for method parameter remove.
-latest See Uploading the most recent file.
-resume
-append
-preservetime
-nopreservetime
-permissions
-nopermissions
-transfer
-filemask
-resumesupport
-speed=<kbps>
Converting transfer settings scripting switches to .NET assembly class TransferSettings.
-neweronly Not supported. Use Session.SynchronizeDirectories instead.

To emulate the (default) option batch abort mode, call TransferOperationResult.Check on method’s result. See also Capturing results of operations.

For example, following script snippet:

cd /home/martinp
lcd d:\
...
put -delete -filemask=*>1M -resumesupport=off *.txt *.xml web/

maps to following PowerShell code:

$transferOptions = New-Object WinSCP.TransferOptions
# -filemask=*>1M
$transferOptions.FileMask = "*>1M"
# -resumesupport=off
$transferOptions.ResumeSupport.State = [WinSCP.TransferResumeSupportState]::Off
# Absolute paths + $True for -delete + Two calls for two source parameters
# + calling Check on result to emulate the (default) "option batch abort" mode
$session.PutFiles("d:\*.txt", "/home/martinp/web/", $True, $transferOptions).Check()
$session.PutFiles("d:\*.xml", "/home/martinp/web/", $True, $transferOptions).Check()

Last modified: by 2.146.8.129