二进制数据过帐与curl [英] Binary Data Posting with curl
问题描述
所以基本上,我试图写一系列脚本来与Dot Net Nuke交互。我一直在分析流量,现在可以登录并做一些基本任务。但是,我从来没有使用curl处理二进制文件上传。有人愿意看这个帮助我吗?以下是请求的解析:
So basically, I'm trying to write a series of scripts to interact with Dot Net Nuke. I've been analysing the traffic and can now login and do some basic tasks. However, I've never handled binary file upload with curl. Would someone be willing to look at this to help me out? Here's the anatomy of the request:
http://pastebin.com / qU8ZEMaQ
这里是我到目前为止的curl:
Here's what I've got for curl so far:
编辑:对于lazy -
edit: For the lazy -
实现文件长度并存储在LENGTH
Bullshit只是请求网址的复制/粘贴参数,减去网址本身。
length of the file is achieved and stored in LENGTH Bullshit is just a copy/paste of the request URL with parameters, minus the URL itself.
curl -L --cookie ~/.cms --data-binary "@background.jpg" \
--header "Content-Length: $LENGTH" \
--header "Content-Disposition: form-data" \
--header "name=\"RadFileExplorer1_upload1file0\"" \
--header "Content-Type: image/jpg" \
--header "Filename=\"background.jpg\"" \
--data $BULLSHIT \
--referer "Kept-Secret" \
"Kept-Secret"
推荐答案
您不需要 - headerContent-Length:$ LENGTH。
查找Google示例:
Look for example for Google example:
http://code.google.com/apis/gdata/articles/using_cURL.html#creating-entries
curl --request POST --data-binary "@template_entry.xml" $URL
请注意,GET请求不支持数据传输。
Note that GET request does not support data transferring.
请记住,POST请求有两种不同的编码模式。这是第一种形式:
Also remember that POST request have 2 different coding schema. This is first form:
$ nc -l -p 6666 &
$ curl --request POST --data-binary "@README" http://localhost:6666
POST / HTTP/1.1
User-Agent: curl/7.21.0 (x86_64-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.15 libssh2/1.2.6
Host: localhost:6666
Accept: */*
Content-Length: 9309
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue
.. -*- mode: rst; coding: cp1251; fill-column: 80 -*-
.. rst2html.py README README.html
.. contents::
你可能请求这个:
-F/--form name=content
(HTTP) This lets curl emulate a filled-in form in
which a user has pressed the submit button. This
causes curl to POST data using the Content- Type
multipart/form-data according to RFC2388. This
enables uploading of binary files etc. To force the
'content' part to be a file, prefix the file name
with an @ sign. To just get the content part from a
file, prefix the file name with the symbol . The
difference between @ and is then that @ makes a
file get attached in the post as a file upload,
while the makes a text field and just get the
contents for that text field from a file.
这篇关于二进制数据过帐与curl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!