我想使用wget将图片上传到远程服务器,使用身份验证令牌'AUTH_1624582364932749DFHDD'到'test'文件夹.
此命令不起作用(授权失败),我想确保它与语法无关:
wget --post-file=nature.jpg http://ipadress:8080/v1/AUTH_test/test/ --post-data="AUTH_1624582364932749DFHDD"
Run Code Online (Sandbox Code Playgroud)
有什么建议?
Max*_*amy 76
--post-file 说:
只应指定--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.
Run Code Online (Sandbox Code Playgroud)
特别是它说:
--post-file不用于将文件作为表单附件传输:这些文件必须显示为"key = value"数据
编辑: 您必须了解"key = value"数据的原理.在POST请求中,如在GET请求中,您必须使用键和值指定数据.这样,服务器将能够接收具有特定名称的多个信息.它与变量类似.
因此,您不能只是向服务器发送魔术令牌,还需要指定密钥的名称.如果密钥是"令牌",那么它应该是key=value&otherkey=example.
此外,如果可以,您应该考虑使用curl,因为使用它更容易发送文件.互联网上有很多例子.