- https://gist.github.com/bewest/6159923 works with restify server
This is an example of how to submit data through post request using both GET params and POST urlencoded parameters, in addition to uploading several more files.
A profile.json is just a demo... could be data2.log, for example.
+ /usr/local/bin/json
+ curl -v -s -X POST -H '' -F '[email protected];type=application/json' -F 'raw_data=@raw_data.log;type=plain/text' -F hello=world -F profile=profile.json -F raw=raw 'http://localhost:5000/api/echo?upload=raw_data.log'
* About to connect() to localhost port 5000 (#0)
* Trying 127.0.0.1... connected
> POST /api/echo?upload=raw_data.log HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: localhost:5000
> Accept: */*
> Content-Length: 1717
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=----------------------------cdf099a4bb93
>
< HTTP/1.1 100 Continue
} [data not shown]
< HTTP/1.1 200 OK
< Content-Type: application/json
< Content-Length: 418
< Date: Fri, 02 Aug 2013 20:47:04 GMT
< Connection: keep-alive
<
{ [data not shown]
* Connection #0 to host localhost left intact
* Closing connection #0
[
"hahaha",
{
"params": {
"upload": "raw_data.log",
"hello": "world",
"profile": "profile.json",
"raw": "raw"
},
"headers": {
"user-agent": "curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3",
"host": "localhost:5000",
"accept": "*/*",
"content-length": "1717",
"expect": "100-continue",
"content-type": "multipart/form-data; boundary=----------------------------cdf099a4bb93"
},
"method": "POST"
}
]
Here are the (heavily deduped) commands I used to create this repo. I edited out bunch of practice runs. You can see how the editing history lines up in revisions.
cd src/gist
[email protected]:6142358.git
# https://gist.github.com/6142358.git
git clone $gist curl_uploads
touch practice.sh
chmod a+xr practice.sh
./practice.sh
./practice.sh | json
./practice.sh | tee out.log
cat out.log
mv out.log baseline-nothing.log
git add baseline-nothing.log
git status
git add practice.sh
git status
git commit -av
git push
./practice.sh
git status
git add out.log
git commit -v
git diff
git show
wc raw_data.log profile.json | tee practice
git diff
rm practice
git status
./practice.sh
git commit -av
git diff
git show
./practice.sh
git commit -avm 'with command'
git push
./practice.sh # 7x
cp out.log some_json.log
git status
git commit -avm 'some json'
git status
git add some_json.log
git commit -avm 'some json'
git push
./practice.sh # 10x
cp out.log all_data.log
git add all_data.log
git commit -avm 'success'
git push
git show
./practice.sh # 4x
mv out.log all_data_2.log
git add all_data*
git commit -av
git push
git show
./practice.sh # 9x
cat profile.json | json
cat profile.json
vim profile.json # match some proposed suggestions
./practice.sh
wc raw_data.log
ls -alh raw_data.log
./practice.sh # 5x
vim raw_data.log
./practice.sh # 6x
wc raw_data.log profile.json | tee -a practice_http_streams.markdown
./practice.sh # 4x
git status
git add out.log
git commit -av 'use form data'
git commit -avm 'use url encoded form data'
git push
./practice.sh
mv out.log pure_json.log
git add pure_json.log
git commit -avm 'as pure json'
git push
./practice.sh # 2x
cp out.log recommended.log
git add recommended.log
git commit -av
git push
./practice.sh
git add README.markdown
git commit -av
git push origin
git diff
git commit -avm 'tweak'
git push
history | grep -E "pract|git|log|json|tee|gist" | tee hist
Works with https://gist.github.com/bewest/6159923