Upload data from stdin as a file with a specific name via cURL
From the cURL man page:
-F/--form
...
You can [...] explicitly change the name field of an file upload part by setting filename=, like this:
curl -F "file=@localfile;filename=nameinpost"
So this is exactly what I wanted. E.g.:
$ echo funfunfun | curl -F file=@-;filename=fun.txt http://etc/upload
I swear I had read the man pages a couple times before asking, but hadn't found that particular paragraph until now.
For protocols other than HTTP, and to use PUT
for HTTP rather than form submission, use -T -
with filename in URL:
echo bla-bla-bla | curl -T - ftp://user:[email protected]/foo.txt