Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to setup a SFTP server, running off Ubuntu Server 11.04. I installed openssh-server to provide SSH access. What I am trying to do is make file uploads run with a suffix (.filepart or whatever), which would be removed upon transfer completion.

The flow idea is:

  1. User uploads cat.jpg
  2. The server starts writing cat.jpg.filepart in the destination directory
  3. Once the upload completes, the server trashes the previous cat.jpg (if any) and renames cat.jpg.filepart to cat.jpg

This is to make sure that incomplete file uploads do not overwrite the existing files. Any idea on how I can do this?

Thanks

share|improve this question
    
I don't think this can be done –  jamespo Jun 22 '11 at 7:34

2 Answers 2

Use rsync (over ssh). It's designed to not destroy existing files if copies fail half way through.

share|improve this answer
    
Well, this is not a viable option since it is supposed to be used by non tech users (read manager, executive class). We can ask them to use SFTP upload because most are familiar with FileZilla/CyberDuck/WinSCP, but certainly not command line + rsync. –  Guillaume Bodi Jun 23 '11 at 2:04

If you are able to write Perl, you could write your customized SFTP server on top of Net::SFTP::Server/Net::SFTP::Server::FS.

Update: see sftp-server-atomic-put.pl

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.