Uploading many files to FTP/SFTP using a temporal name

Andres Ayala via curl-users <[email protected]>
Newsgroups gmane.comp.web.curl.general
Message-ID <BEZP281MB2536A2FEA7357D4DC186919CF8232@BEZP281MB2536.DEUP281.PROD.OUTLOOK.COM>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.