PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 1, 2022

[FIXED] When uploading new files to FTP server, how to prevent reupload of files that were deleted on the server meanwhile

 August 01, 2022     ftp, scp, scriptable, upload, winscp     No comments   

Issue

I need to automate the upload of some files from client PCs to a central server. We're building central statistics for an online gaming community, processing game replay files.

  • target is my own small VPS server running ubuntu
  • upload file size 2-3MB
  • 20-40 different clients running windows spread around the globe
  • I expect ~6GB of wanted data to be uploaded over the course of 7 weeks (a season in our game) and 5-10x that amount of "unwanted" data.

The files are processed on the server, and then they're not required anymore, and ought to be deleted to not run out of disk space eventually. I also only need some of the files, but due to the files requiring very complex processing including decryption, so i can only determine that after the server processed it.

My initial idea was to use a scriptable client such as WinSCP, and use some Windows scheduler entry to automate it. WinSCP documentation looks very nice. I am a bit hesitant because I see the following problems:

  • after deletion on the server, how to prevent re-upload ?
  • ease of setup to technical novices
  • reliability of the solution

I was thinking maybe someone has done the same before and can give some advice.


Solution

There's article on WinSCP site that deals with all this:
How do I transfer new/modified files only?

For advanced logic, like yours, it uses PowerShell script with use of WinSCP .NET assembly.

  • Particularly, there is a section that you will be interested in: Remembering the last timestamp – It shows how to remember the timestamp of the last uploaded file, so that the next time you will transfer only newer files, even if the previously uploaded files are not on the server anymore.

    The example is for downloads with Session.GetFiles, but it will with small changes work for uploads with Session.PutFiles too.

  • It also points to another article: Remember already downloaded files so they are not downloaded again, which shows another method – To store names of already transferrer file to a file and use it the next time to decide, which files are new.



Answered By - Martin Prikryl
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing