Giter Site home page Giter Site logo

Comments (8)

PrzemyslawKlys avatar PrzemyslawKlys commented on May 26, 2024

Does that file "C:\Users\gurki\Documents\Personal_Projects\Algorithms.txt" exists?
I believe RemotePath can't be "C:\Inetpub". THere's no "C:" for remote. do a Get-SFTPList and see how it returns data and use it

Send-SFTPFile -SftpClient $SftpClient -LocalPath $File.FullName -RemotePath "/Temporary/$($File.Name)" -AllowOverride

from transferetto.

g4rry420 avatar g4rry420 commented on May 26, 2024

Thank you for suggesting that. It worked for files but if there is folder and and inside it there are some files, it doesn't send that. Do have any suggestions regarding that ?

I have faced this error when I tried to send the assets folder

Screenshot 2022-03-10 140111

from transferetto.

PrzemyslawKlys avatar PrzemyslawKlys commented on May 26, 2024

Send-SftpDirectory?

from transferetto.

g4rry420 avatar g4rry420 commented on May 26, 2024

This gives me error
Screenshot 2022-03-10 152225
It seems like

FunctionsToExport = @('Compare-FTPFile', 'Connect-FTP', 'Connect-SFTP', 'Connect-SSH', 'Disconnect-FTP', 'Disconnect-SFTP', 'Get-FTPChecksum', 'Get-FTPChmod', 'Get-FTPList', 'Get-SFTPList', 'Move-FTPDirectory', 'Move-FTPFile', 'Receive-FTPDirectory', 'Receive-FTPFile', 'Receive-SFTPFile', 'Remove-FTPDirectory', 'Remove-FTPFile', 'Remove-SFTPFile', 'Rename-FTPFile', 'Rename-SFTPFile', 'Request-FTPConfiguration', 'Send-FTPDirectory', 'Send-FTPFile', 'Send-SFTPFile', 'Send-SSHCommand', 'Set-FTPChmod', 'Set-FTPOption', 'Set-FTPTracing', 'Start-FXPDirectoryTransfer', 'Start-FXPFileTransfer', 'Test-FTPDirectory', 'Test-FTPFile')
, there is not Send-SFTPDirectory command ?

from transferetto.

PrzemyslawKlys avatar PrzemyslawKlys commented on May 26, 2024

Right, then you probably need to do your own logic - for example:

Import-Module .\Transferetto.psd1 -Force

$SftpClient = Connect-SFTP -Server '192.168.241.187' -Verbose -Username 'test' -Password 'BiPassword90A'
Get-SFTPList -SftpClient $SftpClient | Format-Table
Get-SFTPList -SftpClient $SftpClient -Path "/Temporary" | Format-Table *

$ListFiles = Get-ChildItem -LiteralPath $PSScriptRoot\Upload -Recurse -File
foreach ($File in $ListFiles) {
    $Directory = [io.path]::GetDirectoryName($File.FullName)
    if ($Directory -eq "$PSScriptRoot\Upload") {
        Send-SFTPFile -SftpClient $SftpClient -LocalPath $File.FullName -RemotePath "/Temporary/$($File.Name)" -AllowOverride
    } else {
        Send-SFTPFile -SftpClient $SftpClient -LocalPath $File.FullName -RemotePath "/Temporary/$($Directory.Split('\')[-1])/$($File.Name)" -AllowOverride
    }
}

Disconnect-SFTP -SftpClient $SftpClient

from transferetto.

g4rry420 avatar g4rry420 commented on May 26, 2024

I am getting error because the assets folder doesn't exist on the remote. Do you know command to check if the folder exist on the remote and if not, then create that folder ?

from transferetto.

PrzemyslawKlys avatar PrzemyslawKlys commented on May 26, 2024
$SftpClient = Connect-SFTP -Server '192.168.241.187' -Verbose -Username 'test' -Password 'BiPassword90A'
Get-SFTPList -SftpClient $SftpClient | Format-Table
Get-SFTPList -SftpClient $SftpClient -Path "/Temporary" | Format-Table *

$ListFiles = Get-ChildItem -LiteralPath $PSScriptRoot\Upload -Recurse -File
foreach ($File in $ListFiles) {
    $Directory = [io.path]::GetDirectoryName($File.FullName)
    if ($Directory -eq "$PSScriptRoot\Upload") {
        Send-SFTPFile -SftpClient $SftpClient -LocalPath $File.FullName -RemotePath "/Temporary/$($File.Name)" -AllowOverride
    } else {
        #$RemotePath = "/Temporary/$($Directory.Split('\')[-1])/$($File.Name)"
        $RemoteFolder = "/Temporary/$($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

from transferetto.

g4rry420 avatar g4rry420 commented on May 26, 2024

Thank you for this solution.
My apologies, I know I keep on asking you questions.
But the above solution doesn't consider for the nested folder paths
For eg:-

folder1
    nestedFolder1
        file1.txt
    nestedFolder2
        file2.txt
    nestedFolder3
        file3.txt
file1.txt
file2.txt

The above solution do copy all the files but it only considers the folder, in which there are files. So, from above example:

nestedFolder1
     file1.txt
nestedFolder2
     file2.txt
nestedFolder3
     file3.txt
file1.txt
file2.txt

Only, these folder and files exist in the remote. the folder1 doesn't exist on the remote. The reason why it is important for folder1 on exist on remote is beacuse I am pushing the build of site generated onto the remote server.

I am not an expert on powershell. Can you please suggest me solution for this ?

from transferetto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.