transfer_winscp | R Documentation |
transfer_winscp
will connect to the secure file transfer protocol available with winSCP and transfer (upload or download) a specific file of interest.
transfer_winscp(
file = NULL,
direction = NULL,
connection = NULL,
rmt_path = NULL,
drop_location = NULL,
options = NULL,
winscp_location = "C:/Program Files (x86)/WinSCP/winSCP.com",
...
)
file |
Character string. When uploading, should be the file path and name, when downloading it should just be the file name and extension. |
direction |
Character string, either 'upload' or 'download'. |
connection |
Character string that is used to connect to the desired file system. Usually the password and username can be provided as part of the address. |
rmt_path |
Character string describing the file path to upload to or download from. If none provided, default to home directory. For example: sftp://USERNAME:PASSWORD@SERVERADDRESS.CA/ |
drop_location |
Character string that provides the path to place the downloaded file from winSCP. |
options |
Character string for command line options to winSCP (e.g. for permissions). |
winscp_location |
Character string, defining the location of the install location for winSCP. Default is C:/Program Files (x86)/WinSCP/winSCP.com. |
... |
Additional parameters that will be passed to |
This function uses check_winscp
during the download operation to ensure the file actually exists.
The remote location requires the directory to end in '/', the drop_location
must end in a backslash as well; several checks exist in the code to ensure this.
If the code is not operating, try to add double quotes around a string that contains spaces. The paths are normalized to windows when passing to the windows command
prompt; however, the commands in winSCP console follow a UNIX style. The function will create a batch file temporarily that is passed to winSCP through command prompt, the
subsequent output is captured and the operation of data transfer is performed.
Options can be provided to the transfer, which may be helpful for changing permissions (e.g. -permissions=640
to allow group read). Note that only
some options are available for upload (put
) as compared to download (get
). See more at: https://winscp.net/eng/docs/scriptcommand_put and https://winscp.net/eng/docs/scriptcommand_get
Dataset will be saved in the file system.
## Not run:
# Download a file
transfer_winscp(file ='filename_in_remote_location.xlsx'),
direction = 'download',
connection = 'sftp://######:######@hostlocation.ca/'
rmt_path = './location/',
drop_location = 'C:/PATH/TO/DESIRED/FOLDER/')
# Upload a file
transfer_winscp(file = 'C:/LOCATION/OF/FILE/UPLOAD.csv, direction = 'upload',
connection = 'sftp://######:######@hostlocation.ca/',
rmt_location = './location/')
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.