intermittent .filepart generation?

Advertisement

tl5k5
Joined:
Posts:
5

intermittent .filepart generation?

Hello,
I've been working all day trying to get an automated SFTP PowerShell script working to my liking. Before today, I've never done any scripting other than a "Hello World".
Everything seemed to be working well at the end of the day, but when I tried a different file type/extension, the SFTP location started to show .filepart files again after fixing this issue earlier in the day by injecting the following code into my script:
$transferOptions = New-Object WinSCP.TransferOptions -Property @{
    PreserveTimestamp = $False
    ResumeSupport = New-Object WinSCP.TransferResumeSupport -Property @{ State = [WinSCP.TransferResumeSupportState]::Off }
Any ideas as to why .mp4 files transfer to the SFTP server without a .filepart, while .mxf files do generate the .filepart files?

Thanks!

Reply with quote

Advertisement

tl5k5

I'm still trying to troubleshoot the script and get logs.
Question: Smaller files (20MB) do not seem to generate ".filepart" files and larger files (250MB) do. Could there be a file size issue with the TransferResumeSupport option?

Reply with quote

tl5k5
Joined:
Posts:
5

I've tested throughout the day, and I'm still getting .filepart files on the SFTP server.
I would greatly appreciate you looking over this script and log.
Thank you!

Script:
$srcPath = '\\path\to\files\*.*'
$filePath = Get-ChildItem $srcpath -File
 
$tarpath = '*'
 
$comPath = '\\path\to\uploaded\'
 
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"
 
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$sessionOptions.HostName = "sftp.url"
$sessionOptions.UserName = "xxxxxxx"
$sessionOptions.Password = "xxxxxxx"
$sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxxxxxx"
 
### Initiate Connection and Transfer ###
 
$session = New-Object WinSCP.Session
 
Try
{
    $session.SessionLogPath = "C:\logs\winscp.log"
    # Connect
    $session.Open($SessionOptions)
    
    # Set up transfer options
    $transferOptions = New-Object WinSCP.TransferOptions -Property @{
        PreserveTimestamp = $False
        ResumeSupport = New-Object WinSCP.TransferResumeSupport -Property @{ State = [WinSCP.TransferResumeSupportState]::Off }
    }
    $transferOptions.AddRawSettings("NewerOnly", "1")
    $transferOptions.AddRawSettings("ExcludeHiddenFiles", "1")
 
    foreach ($file in $filePath){
        #Upload files, collect results
        $transferResult = $session.PutFiles($file, $tarPath, $False, $options)
 
        # Iterate over every transfer
        foreach ($transfer in $transferResult.Transfers)
        {
            # Success or error?
            if ($transfer.Error -eq $Null)
            {
                Write-Host "Upload of $($transfer.FileName) succeeded, moving to completed path"
                #Upload succeeded, move source file to backup
                Move-Item $transfer.FileName $comPath
            }
            else
            {
                Write-Host "Upload of $($transfer.FileName) failed: $($transfer.Error.Message)"
            }
        }
    }
}
finally
{
    # Disconnect, clean up
    $session.Dispose()
}
Last edited by tl5k5 on 2024-03-14 20:07; edited 1 time in total

Reply with quote

Advertisement

tl5k5
Joined:
Posts:
5

FIXED!

A coder friend help me fix my issue. The following line was adjusted:
$transferResult = $session.PutFiles($file, $tarPath, $False, $transferOptions)
Thanks for your assistance!

Reply with quote

Advertisement

You can post new topics in this forum