使用 CURL 我可以像这样上传文件:
当我在服务器端打开文件时,文件包含以下内容:
请建议我如何实现这个目标。
CURL -X POST -d "pxeconfig=`cat boot.txt`" https://ip:8443/tftp/syslinux
我的文件看起来像这样
$ cat boot.txt
line 1
line 2
line 3
我正在尝试使用 Python 中的 requests 模块实现相同的功能。
r=requests.post(url, files={'pxeconfig': open('boot.txt','rb')})
当我在服务器端打开文件时,文件包含以下内容:
{:filename=>"boot.txt", :type=>nil, :name=>"pxeconfig",
:tempfile=>#<Tempfile:/tmp/RackMultipart20170405-19742-1cylrpm.txt>,
:head=>"Content-Disposition: form-data; name=\"pxeconfig\";
filename=\"boot.txt\"\r\n"}
请建议我如何实现这个目标。