LoginSignup
0
0

More than 3 years have passed since last update.

POSTするデータを標準入力から取り込ませてそのままWebサーバにPOSTさせる方法

Posted at

elasticsearchでタイプを追加する際などに使用。
POSTする際のデータをファイルに作成しておいて、標準出力からそのままcurlのデータを付与してリクエストする方法。

@-をつける

POSTする本体を標準入力から取り込ませてそのままWebサーバにPOSTさせるには、
オプションとして-d @-をつける。

cat foo.txt | curl  http://www.example.com/ -XPOST -d @-

foo.txtにはデータを記載している。
作業履歴を残すためにも、catで出力しているのかも?

ちなみに、ファイル名を直接指定する方法もある。

curl  http://www.example.com/ -XPOST -d foo.txt

参照:https://hydrocul.github.io/wiki/commands/curl.html

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0