vsftpd – is it possible to upload local file to FTP server with filename change?

I need to upload a local file from an Ubuntu desktop to an FTP server in a one-liner, while also changing the filename to be unique – by adding a timestamp to the beginning of the filename, for example.
Is it possible to do it in an easy way?
I know that I can upload a file to an FTP server using curl -T, but it doesn’t seem to have an option for indicating a new name for the file, unfortunately.

Answer

man curl

-T , --upload-file <file>

This transfers the specified local file to the remote URL. If there is no file part in the specified URL, curl will append the local file name.

In other words: only when you don’t set the desired remote filename in the URL it will be the same as the file name of the source. You simply need to do something like for instance:

curl -T "localfile.png" ftp://ftp.example.com/upload/$(date +%s)-remote-file.png

Attribution
Source : Link , Question Author : 0lesya , Answer Author : Community

Leave a Comment