向Wget发送请求?

我想使用wget将图片上传到远程服务器,使用身份validation令牌:“AUTH_1624582364932749DFHDD”到“testing”文件夹。

此命令不起作用(授权失败),我想确保它不是关于语法:

wget --post-file=nature.jpg http://ipadress:8080/v1/AUTH_test/test/ --post-data="AUTH_1624582364932749DFHDD" 

有什么build议么 ?

Solutions Collecting From Web of "向Wget发送请求?"

man wget说:

只应该指定–post-data和–post-file之一。

完整段落是:

  --post-data=string --post-file=file Use POST as the method for all HTTP requests and send the specified data in the request body. --post-data sends string as data, whereas --post-file sends the contents of file. Other than that, they work in exactly the same way. In particular, they both expect content of the form "key1=value1&key2=value2", with percent-encoding for special characters; the only difference is that one expects its content as a command-line parameter and the other accepts its content from a file. In particular, --post-file is not for transmitting files as form attachments: those must appear as "key=value" data (with appropriate percent-coding) just like everything else. Wget does not currently support "multipart/form-data" for transmitting POST data; only "application/x-www-form-urlencoded". Only one of --post-data and --post-file should be specified. 

特别是说:

– 邮件文件不是以表单附件的形式传输文件:那些文件必须显示为“key = value”数据

编辑:您必须了解“key = value”数据的原理。 在POST请求中,与GET请求一样,您必须使用键和值来指定数据。 这样服务器将能够接收具有特定名称的多个信息。 它与变量类似。

因此,你不能只发送一个神奇的令牌给服务器,你还需要指定密钥的名称。 如果密钥是“令牌”,那么它应该是token=YOUR_TOKEN

此外,你应该考虑使用curl,如果可以的话,因为使用它更容易发送文件。 互联网上有很多这样的例子。