curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Uploading many files to FTP/SFTP using a temporal name

From: Andres Ayala via curl-users <curl-users_at_lists.haxx.se>
Date: Mon, 4 Mar 2024 09:43:57 +0000

Hello,

I am trying to upload several files to the same server.
I need to use a temporal name during the transfer and only rename the file once the transfer is completed.

Transferring a single file worked fine using a batch file like:
  insecure
  no-progress-meter
  user = "fulanito:Secret"
  ftp-create-dirs
  upload-file = "/path/to/workdir/file_0.txt"
  url = "ftp://ftp.example.com/target/folder/file_0.txt.tmp"
  quote = "-RNFR target/folder/file_0.txt.tmp"
  quote = "-RNTO target/folder/file_0.txt"

The problem is when we try to upload two files:
  insecure
  no-progress-meter
  user = "fulanito:Secret"
  ftp-create-dirs
  upload-file = "/path/to/workdir/file_0.txt"
  url = "ftp://ftp.example.com/target/folder/file_0.txt.tmp"
  quote = "-RNFR target/folder/file_0.txt.tmp"
  quote = "-RNTO target/folder/file_0.txt"
  upload-file = "/path/to/workdir/file_1.txt"
  url = "ftp://ftp.example.com/target/folder/file_1.txt.tmp"
  quote = "-RNFR target/folder/file_1.txt.tmp"
  quote = "-RNTO target/folder/file_1.txt"

That we receive an error:
(21) QUOT string not accepted: RNFR target/folder/file_1.txt.tmp

Looking at the documentation of the "quote" command it seems that all the quote commands (with -) are sent after each successful transfer.
This means that after transferring the file_0.txt.tmp CURL sends also the commands to rename file_1.txt.tmp and fails.

I tried to use the "--next" option but it seems it reconnect each time to the FTP server (at least we need to give again the user credentials)

The only workaround we have found is to use "-*RNFR" and "-*RNTO" so the fails are ignored, but

How I can do that curl applies the quotes only to the last defined url? I am thinking in something like a "--blockquote" that group quote commands with the last defined url, but I might be completely wrong and the solution goes in a completely different direction.

Thanks!
Andrés Ayala


Any email message from EUMETSAT is sent in good faith but shall neither be binding nor construed as constituting a commitment by EUMETSAT, except where provided for in a written agreement or contract or if explicitly stated in the email. Please note that any views or opinions presented in this email are solely those of the sender and do not necessarily represent those of EUMETSAT. This message and any attachments are intended for the sole use of the addressee(s) and may contain confidential and privileged information. Any unauthorised use, disclosure, dissemination or distribution (in whole or in part) of its contents is not permitted. If you received this message in error, please notify the sender and delete it from your system.
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2024-03-04