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.

Re: Specify multiple "@" files for --data

From: Daniel Stenberg via curl-users <curl-users_at_cool.haxx.se>
Date: Fri, 17 Jan 2020 07:49:16 +0100 (CET)

On Thu, 16 Jan 2020, Norton, Mike via curl-users wrote:

> This is regarding "--data" (-d) - according to manpage:
>
>> If you start the data with the letter @, the rest should be a file name
>> to read the data from, or - if you want curl to read the data from
>> stdin. Multiple files can also be specified.
>
> Unfortunately, I cannot find the part of the manpage that tells HOW to
> specify multiple files. I've tried commas, semicolons, quoted space,
> multiple @ characters... everything I could think of results in Curl
> treating whatever I specify as if it was all a single filename. Anyone?

The wording there is slightly misleading. You don't specify multiple files
with *one* --data flag, you use multiple. (Although I wouldn't mind supporting
exactly what you're asking for, somehow.)

> I am aware of the possibility to use "--data" more than once, but that
> separates the data with the "&" character, which is not the behaviour I
> want.

There are two ways to accomplish that. One is using a temp file, one using
stdin:

  $ cat file1 file2 > uploadfile
  $ curl -d @uploadfile $URL
  $ rm uploadfile

and

  $ cat file1 file2 | curl -d_at_- $URL

-- 
  / daniel.haxx.se | Commercial curl support up to 24x7 is available!
                   | Private help, bug fixes, support, ports, new features
                   | https://www.wolfssl.com/contact/
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2020-01-17