• November 9, 2022

Curl File

HTTP & SOCKS Rotating Residential Proxies

  • 32 million IPs for all purposes
  • Worldwide locations
  • 3 day moneyback guarantee

Visit shifter.io

Send request to cURL with post data sourced from a file

I need to make a POST request via cURL from the command line. Data for this request is located in a file. I know that via PUT this could be done with the –upload-file option.
curl host:port/post-file -H “Content-Type: text/xml” –data “contents_of_file”
22401, 5121 gold badge7 silver badges21 bronze badges
asked Jun 20 ’11 at 9:02
You’re looking for the –data-binary argument:
curl -i -X POST host:port/post-file \
-H “Content-Type: text/xml” \
–data-binary “@path/to/file”
In the example above, -i prints out all the headers so that you can see what’s going on, and -X POST makes it explicit that this is a post. Both of these can be safely omitted without changing the behaviour on the wire. The path to the file needs to be preceded by an @ symbol, so curl knows to read from a file.
Marian13. 6k5 gold badges30 silver badges41 bronze badges
answered Jun 20 ’11 at 9:13
Richard JRichard J5, 8634 gold badges20 silver badges25 bronze badges
I need to make a POST request via Curl from the command line. Data for this request is located in a file…
All you need to do is have the –data argument start with a @:
curl -H “Content-Type: text/xml” –data “@path_of_file” host:port/post-file-path
For example, if you have the data in a file called then you would do something like:
curl -H “Content-Type: text/xml” –data “” host:port/post-file-path
The filename can be replaced with a relative or full path to the file: @.. /xml/, @/var/tmp/,…
slartidan17. 9k11 gold badges75 silver badges118 bronze badges
answered Nov 3 ’17 at 17:58
GrayGray110k22 gold badges277 silver badges337 bronze badges
If you are using form data to upload file, in which a parameter name must be specified, you can use:
curl -X POST -i -F “[email protected]” -F “additional_parm=param2” host:port/xxx
alessiosavi1, 9552 gold badges10 silver badges28 bronze badges
answered Jan 5 ’17 at 10:32
Lucas LiuLucas Liu6831 gold badge7 silver badges12 bronze badges
Most of answers are perfect here, but when I landed here for my particular problem, I have to upload binary file (XLSX spread sheet) using POST method, I see one thing missing, i. e. usually its not just file you load, you may have more form data elements, like comment to file or tags to file etc as was my case. Hence, I would like to add it here as it was my use case, so that it could help others.
curl -POST -F comment=mycomment -F file_type=XLSX -F [email protected]/your/path/to/
gudok3, 7492 gold badges17 silver badges29 bronze badges
answered Sep 3 ’18 at 11:08
Red BoyRed Boy4, 5742 gold badges23 silver badges35 bronze badges
Not the answer you’re looking for? Browse other questions tagged curl -post command-line-interface or ask your own question.
Downloading files with curl - Computational Methods in the ...

Datacenter proxies

  • Price $1.3/IP
  • Locations: DE, RU, US
  • 5% OFF coupon: APFkysWLpG

Visit proxy6.net

Downloading files with curl – Computational Methods in the …

The curl tool lets us fetch a given URL from the command-line. Sometimes we want to save a web file to our own computer. Other times we might pipe it directly into another program. Either way, curl has us covered.
See its documentation here.
This is the basic usage of curl:
curl –output
That –output flag denotes the filename () of the downloaded URL ()
Let’s try it with a basic website address:
Besides the display of a progress indicator (which I explain below), you don’t have much indication of what curl actually downloaded. So let’s confirm that a file named was actually downloaded.
Using the ls command will show the contents of the directory:
Which outputs:
And if you use cat to output the contents of, like so:
– you will the HTML that powers
I thought Unix was supposed to be quiet?
Let’s back up a bit: when you first ran the curl command, you might have seen a quick blip of a progress indicator:% Total% Received% Xferd Average Speed Time Time
Dload Upload Total Spent
100 1270 100 1270 0 0 50573 0 –:–:– –:–:–
If you remember the Basics of the Unix Philosophy, one of the tenets is:
Rule of Silence: When a program has nothing surprising to say, it should say nothing.
In the example of curl, the author apparently believes that it’s important to tell the user the progress of the download. For a very small file, that status display is not terribly helpful. Let’s try it with a bigger file (this is the baby names file from the Social Security Administration) to see how the progress indicator animates:
curl \
Quick note: If you’re new to the command-line, you’re probably used to commands executing every time you hit Enter. In this case, the command is so long (because of the URL) that I broke it down into two lines with the use of the backslash, i. e. \
This is solely to make it easier for you to read. As far as the computer cares, it just joins the two lines together as if that backslash weren’t there and runs it as one command.
Make curl silent
The curl progress indicator is a nice affordance, but let’s just see if we get curl to act like all of our Unix tools. In curl’s documentation of options, there is an option for silence:
-s, –silent
Silent or quiet mode. Don’t show progress meter or error messages. Makes Curl mute. It will still output the data you ask for, potentially even to the terminal/stdout unless you redirect it.
Try it out:
curl –output –silent
Repeat and break things
So those are the basics for the curl command. There are many, many more options, but for now, we know how to use curl to do something that is actually quite powerful: fetch a file, anywhere on the Internet, from the simple confines of our command-line.
Before we go further, though, let’s look at the various ways this simple command can be re-written and, more crucially, screwed up:
Shortened options
As you might have noticed in the –silent documentation, it lists the alternative form of -s. Many options for many tools have a shortened alias. In fact, –output can be shortened to -o
curl -o -s
Now watch out: the number of hyphens is not something you can mess up on; the following commands would cause an error or other unexpected behavior:
curl -o -silent
curl -output -s
curl –o –s
Also, mind the position of, which can be thought of as the argument to the -o option. The argument must follow after the -o…because curl.
If you instead executed this:
How would curl know that, and not -s is the argument, i. what you want to name the content of the downloaded URL?
In fact, you might see that you’ve created a file named -s…which is not the end of the world, but not something you want to happen unwittingly.
Order of options
By and large (from what I can think of at the top of my head), the order of the options doesn’t matter:
curl -s -o
In fact, the URL,, can be placed anywhere in the mix:
A couple of things to note:
The way that the URL, what you might consider the main argument for the curl command, can be placed anywhere after the command is not the way that all commands have been designed. So it always pays to read the documentation with every new command.
Notice how -s doesn’t cause a problem. That’s because the -s option doesn’t take an argument. But try the following:
And you will have a problem.
No options at all
The last thing to consider is what happens when you just curl for a URL with no options (which, after all, should be optional). Before you try it, think about another part of the Unix philosophy:
This is the Unix philosophy: Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.
If you curl without any options except for the URL, the content of the URL (whether it’s a webpage, or a binary file, such as an image or a zip file) will be printed out to screen. Try it:

Example Domain

… (and so forth)
Even with the small amount of HTML code that makes up the webpage, it’s too much for human eyes to process (and reading raw HTML wasn’t meant for humans).
Standard output and connecting programs
But what if we wanted to send the contents of a web file to another program? Maybe to wc, which is used to count words and lines? Then we can use the powerful Unix feature of pipes. In this example, I’m using curl’s silent option so that only the output of wc (and not the progress indicator) is seen. Also, I’m using the -l option for wc to just get the number of lines in the HTML for
curl -s | wc -l
Number of lines in is: 50
Now, you could’ve also done the same in two lines:
wc -l
But not only is that less elegant, it also requires creating a new file called Now, this is a trivial concern, but someday, you may work with systems and data flows in which temporarily saving a file is not an available luxury (think of massive files).
cURL - Wikipedia

cURL – Wikipedia

cURLExample output from curl -OOriginal author(s)Daniel Stenberg[1]Developer(s)Contributors to the cURL projectInitial release1996; 25 years ago[2]Stable release7. 79. 1[3]
/ 22 September 2021; 15 days
Written inCOperating system
Chrome NaCl
DragonFly BSD
Midnight BSD
Open Server
Tru64 UNIX
Microsoft Windows
PlatformCross-platformTypeFTP client / HTTP clientLicensecurl[4][5]
cURL (pronounced like “curl”, /kɜːl/[6]) is a computer software project providing a library (libcurl) and command-line tool (curl) for transferring data using various network protocols. The name stands for “Client URL”, [7] which was first released in 1996. [8]
cURL was first released in 1996. [8] It was originally named get and then became urlget before adopting the current name of cURL. [9][10] The original author and lead developer is the Swedish developer Daniel Stenberg, who created cURL because he wanted to automate the fetching of currency exchange rates for IRC users. [2]
libcurl is a free client-side URL transfer library, [11] supporting cookies, DICT, FTP, FTPS, Gopher, HTTP/1[12] (with HTTP/2 and HTTP/3 support), HTTP POST, HTTP PUT, HTTP proxy tunneling, HTTPS, IMAP, Kerberos, LDAP, MQTT, POP3, RTSP, RTMP, SCP, SMTP, and SMB. The library supports the file URI scheme, SFTP, Telnet, TFTP, file transfer resume, FTP uploading, HTTP form-based upload, HTTPS certificates, LDAPS, proxies, and user-plus-password authentication. [13]
The libcurl library is portable. It builds and works identically on many platforms, including AIX, AmigaOS, Android, BeOS, BlackBerry Tablet OS and BlackBerry 10, [14] OpenVMS, Darwin, DOS, FreeBSD, HP-UX, HURD, iOS, IRIX, Linux, macOS, NetBSD, NetWare, OpenBSD, OS/2, QNX Neutrino, RISC OS, Solaris, Symbian, Tru64, Ultrix, UnixWare, and Microsoft Windows.
The libcurl library is free, thread-safe and IPv6 compatible. Bindings are available for more than 50 languages, including C/C++, Java, PHP and Python. [16]
The libcurl library supports GnuTLS, mbed TLS, NSS, gskit on IBM i, SChannel on Windows, Secure Transport on macOS and iOS, SSL/TLS through OpenSSL, Boringssl, libressl, AmiSSL, wolfSSL, BearSSL, Mesalink and rustls. [citation needed]
cURL is a command-line tool for getting or sending data including files using URL syntax. Since cURL uses libcurl, it supports every protocol libcurl supports. [13]
cURL supports HTTPS and performs SSL certificate verification by default when a secure protocol is specified such as HTTPS. When cURL connects to a remote server via HTTPS, it will obtain the remote server certificate, then check against its CA certificate store the validity of the remote server to ensure the remote server is the one it claims to be. Some cURL packages are bundled with CA certificate store file. There are several options to specify a CA certificate such as –cacert and –capath. The –cacert option can be used to specify the location of the CA certificate store file. In the Windows platform, if a CA certificate file is not specified, cURL will look for a CA certificate file name “” in the following order:
Directory where the cURL program is located.
Current working directory.
Windows system directory.
Windows directory.
Directories specified in the%PATH% environment variables. [17]
cURL will return an error message if the remote server is using a self-signed certificate, or if the remote server certificate is not signed by a CA listed in the CA cert file. -k or –insecure option can be used to skip certificate verification. Alternatively, if the remote server is trusted, the remote server CA certificate can be added to the CA certificate store file.
Basic use of cURL involves simply typing curl at the command line, followed by the URL of the output to retrieve:
cURL defaults to displaying the output it retrieves to the standard output specified on the system (usually the terminal window). So running the command above would, on most systems, display the source-code in the terminal window. The -o flag can be used to store the output in a file instead:
$ curl -o
More options that change the tool’s behavior are available.
See also[edit]
curl-loader – an open-source testing tool based on cURL
libwww – an early library that comes with a command line interface
PowerShell – the iwr (Invoke-WebRequest) Windows PowerShell had functionality akin to curl; class Web-client too. [18]
Web crawler – an internet bot that can crawl the web
Wget – similar command-line tool with no associated library but capable of recursive downloading.
^ Stenberg, Daniel (20 March 2015). “curl, 17 years old today”. Retrieved 20 March 2015.
^ a b “History of curl – How curl Became Like This”. curl. Archived from the original on September 30, 2017. Retrieved November 17, 2016. Daniel simply adopted an existing command-line open-source tool, get, that Brazilian Rafael Sagula had written and recently release version 0. 1 of. After a few minor adjustments, it did just what he needed. […] HttpGet 1. 0 was released on April 8th 1997 with brand new HTTP proxy support. […] Stenberg was spending time writing an IRC bot for an Amiga related channel on EFnet. He then came up with the idea to make currency-exchange calculations available to Internet Relay Chat (IRC) users.
^ “Release 7. 1”. 22 September 2021. Retrieved 23 September 2021.
^ “curl License”.
^ “curl – copyright”.
^ “curl – Frequently Asked Questions”.
^ Stenberg, Daniel. “Origin of the name”. Retrieved 2018-04-25.
^ a b “History of curl”. Archived from the original on September 29, 2021.
^ “Changelog”. 4 January 2020. Retrieved 4 January 2020. The first curl release. The tool was named urlget before this. And get before that.
^ Stenberg, Daniel (4 January 2020). “Restored complete curl changelog” (html). Haxx Se. Retrieved 2 January 2020.
^ Jones, M. Tim (8 September 2009). “Conversing through the Internet with cURL and libcurl – Using libcurl with C and Python”. IBM Developerworks. Archived from the original on 14 April 2015. Retrieved 12 September 2018.
^ Stenberg, Daniel (5 August 2019). “09: disable HTTP/0. 9 by default in both tool and library”. GitHub. Archived from the original (html) on 5 August 2019. Retrieved 5 August 2019. As the plan has been laid out in Deprecated. Update docs accordingly and verify in test 1174.
^ a b “curl – How To Use”.
^ “Open Source Components for the Native SDK for BlackBerry Tablet OS”. Archived from the original on 2013-01-27. Retrieved 2017-09-19.
^ “libcurl bindings”.
^ “curl – SSL CA Certificates”.
^ Del, Ryan (2 March 2018). “Comandi equivalenti a cURL e Wget per Windows command-line con Powershell” [cURL and Wget equivalent commands for Windows command-line with Powershell] (html). Ryadel (in Italian). Per emulare il comportamento del comando Linux cURL, è sufficiente creare un file 1 contenente la seguente riga di codice
External links[edit]
Official website
Comparison of cURL vs other open source download tools
Comparison of cURL vs wget

Frequently Asked Questions about curl file

What is a curl file?

cURL is a command-line tool for getting or sending data including files using URL syntax. Since cURL uses libcurl, it supports every protocol libcurl supports. cURL supports HTTPS and performs SSL certificate verification by default when a secure protocol is specified such as HTTPS.

How do I run a curl file?

Testing your cURL installationLaunch your command-line interface. In Windows, open the Start menu, type cmd in the search box, and press Enter. … Copy the cURL statement from your text file and paste it at the command prompt. … Press Enter to run the cURL statement.

What is curl and why it is used?

cURL is a command-line tool that you can use to transfer data via network protocols. The name cURL stands for ‘Client URL’, and is also written as ‘curl’. This popular command uses URL syntax to transfer data to and from servers. Curl is powered by ‘libcurl’, a free and easy-to-use client-side URL transfer library.Dec 23, 2020

Leave a Reply

Your email address will not be published. Required fields are marked *