PutFiles / Check ends up uploading files multiple times

Advertisement

mariant
Guest

PutFiles / Check ends up uploading files multiple times

Hi there,

This might be a server-side-caused-problem, but ...

I have a process where I upload files on SFTP protocol and then check for errors.
The files are in a Outbox folder when picked up by PutFiles.... then I call the Check().
From the transferResult.Transfers collection I take file by file and create my log and move the files to an Archive folder.
Everything works fine on my side, but on the server side, a file looks like it is uploaded multiple times ("they" have a log showing multiple uploads), and that might be because the destination file gets picked up "too quick" before my process ends.

Can someone explain why/how PutFiles works and why is re-uploading files?
As a note, the ResumeSupport is set to off.


Thanks

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,291
Location:
Prague, Czechia

Re: PutFiles / Check ends up uploading files multiple times

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

mariant
Guest

Re: PutFiles / Check ends up uploading files multiple times

Hi,

I am attaching here the session log.
It is the entire log generated while I was trying to upload a 74 KB file.
There seems to be a "Network error: Software caused connection abort".

The log I generate inside my code does not capture an error.

These are some lines from the log I generate:
2019-03-28 12:20:12.668 | Connect to WinSCP.
2019-03-28 12:20:16.944 | Try upload all files in Outbox folder...
2019-03-28 12:20:37.732 | ...Done
2019-03-28 12:20:37.741 | Uploaded Files: 1, Files Failed: 0
And this is the relevant code that produces the above 4 lines of log.
// Connect
Add2Log("Connect to WinSCP.");
session.Open(sessionOptions);
 
// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Automatic;
transferOptions.PreserveTimestamp = false;
transferOptions.ResumeSupport.State = TransferResumeSupportState.Off;
 
TransferOperationResult transferResult;
 
Add2Log("Try upload all files in Outbox folder...");
transferResult = session.PutFiles(
      outboxFolder + "*"
    , remoteFolder
    , false
    , transferOptions
  );
// Throw on any error
transferResult.Check();
Add2Log("...Done");
Add2Log(string.Format(
     "Uploaded Files: {0}, Files Failed: {1}"
    , transferResult.Transfers.Count
    , transferResult.Failures.Count
  ));
Thanks

Reply with quote

kimxavier.nati@encorebusiness.com
Joined:
Posts:
1

PutFiles uploads the file twice to SFTP site

Hi,

I am encountering a similar issue on the SFTP side after uploading a file using a PowerShell script Session.PutFiles. The file looks to be uploaded twice, second file with an _1 after the extension e.g. kim.xml, kim.xml_1.

Logs show there's only 1 file getting copied or processed though.

Here's the script
$session = New-Object WinSCP.Session
$session.SessionLogPath = $logPath
 
# Connect
$session.Open($sessionOptions)
 
# Upload files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
 
$transferResult =
    $session.PutFiles($localPath, $remotePath)
 
# Throw on any error
$transferResult.Check()
 
Write-Host "Transfer count: " $transferResult.Transfers.Count
Attached is the modified log to remove sensitive data.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,291
Location:
Prague, Czechia

Re: PutFiles uploads the file twice to SFTP site

@kimxavier.nati: As you yourself noticed, WinSCP uploads the file only once. If you end up with two files, it must be the server's doing. Did you try to upload the file in WinSCP GUI or even better using any other SFTP client? You will most likely see the same behavior.
Might be a variant of:
Why is uploaded file not showing in a remote directory or showing with a different name?

Reply with quote

Advertisement

You can post new topics in this forum