-
-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
enhancementNew feature or requestNew feature or request
Description
I'm using your SFTP uploading example here: https://github.com/EvotecIT/Transferetto/blob/master/Examples/Example07-UploadSFTP.ps1 and it works GREAT except when a folder to be uploaded has a space in the folder name.
Example: /uploads/folder/sub folder/* is placed at the root uploads folder, rather than under /uploads/folder/*
(I hope this made sense)
This is the script I used:
$SftpClient = Connect-SFTP -Server 'sftp.server.com' -Username "test.user" -PrivateKey "C:\Path\to\My\Private_key" -Verbose
$ListFiles = Get-ChildItem -LiteralPath "C:\BoxTesting" -Recurse -File
foreach ($File in $ListFiles) {
$Directory = [io.path]::GetDirectoryName($File.FullName)
if ($Directory -eq "C:\BoxTesting") {
Send-SFTPFile -SftpClient $SftpClient -LocalPath $File.FullName -RemotePath "/dataplatform-sftp-bucket-1234567890/$($File.Name)" -AllowOverride
} else {
#$RemotePath = "/dataplatform-sftp-bucket-1234567890/$($Directory.Split('\')[-1])/$($File.Name)"
$RemoteFolder = "/dataplatform-sftp-bucket-1234567890/$($Directory.Split('\')[-1])"
$List = Get-SFTPList -SftpClient $SftpClient -Path $RemoteFolder -WarningAction SilentlyContinue
if (-not $List) {
$SftpClient.CreateDirectory($RemoteFolder)
}
Send-SFTPFile -SftpClient $SftpClient -LocalPath $File.FullName -RemotePath "$RemoteFolder/$($File.Name)" -AllowOverride
}
}
Disconnect-SFTP -SftpClient $SftpClient
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request