cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: remote file size

From: Jim Young <j4young_at_gmail.com>
Date: Wed, 11 May 2016 16:25:38 -0500
On 5/11/2016 9:25 AM, ganesh patwardhan via curl-users wrote:

           Is there any way to find out file size at FTP/SFTP server using 'curl' command.

My use case is:
I will transfer file using curl (ftp/sftp) to server
I want to read back file size from destination once transfer is complete.
(I don't want to rely on success message from curl to assume complete file is transferred and written at destination )

What I did to validate that the file was successfully transferred was to have curl print out the upload size with the -W option.  I'd then check that against the file size on my local machine, (compensating for MS DOS vs. UNIX line ending differences if need be.)  Here's a snip from my UNIX shell script that captures the size:

     FTPSIZE=`$CURL -u $AUTH $CURLOPT -T "$FROMDIR/$FILE" $URL//$HOST/$TMPDIR/ -w '%{size_upload}' `

Another possibility would be to list out the file on the remote system and capture the file size reported there to compare with your local file size.

Jim Young

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-users
FAQ: https://curl.haxx.se/docs/faq.html
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-05-11