Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL - Use cURL to ftp files and keep the original timestamp of file

I am using curl to download some files from a FTPS site. When i download the files from site to my machine the zip files date changes to the download time and date. I want to keep the original timestamp that is on the FTPS server. Please advise how to do this. If you can provide examples that would be gr8 i am new to curl.

Thanks

like image 756
arthur Avatar asked Apr 05 '11 19:04

arthur


People also ask

Does curl work with FTP?

curl is the goto tool for anything HTTP related but you can also use it for your FTP and FTPS tasks.

How do I upload to FTP using curl?

To upload to an FTP server, you specify the entire target file path and name in the URL, and you specify the local file name to upload with -T, --upload-file . Optionally, you end the target URL with a slash and then the file component from the local path will be appended by curl and used as the remote file name.

Does curl save files?

To download a file with Curl, use the --output or -o command-line option. This option allows you to save the downloaded file to a local drive under the specified name. If you want the uploaded file to be saved under the same name as in the URL, use the --remote-name or -O command line option.

How do I save a curl script?

We can save the result of the curl command to a file by using -o/-O options. Now the page gettext. html will be saved in the file named 'mygettext.


1 Answers

The key is this command line option:

   -R/--remote-time
          When  used,  this  will make libcurl attempt to figure out the
          timestamp of the remote file, and if that  is  available  make
          the local file get that same timestamp.

... which then can be used like:

curl -R -O --ssl ftp://example.com/that/file/I/want.txt

(--ssl was formerly known as --ftp-ssl)

like image 70
Daniel Stenberg Avatar answered Oct 02 '22 20:10

Daniel Stenberg