Reputation: 170
I have python3
script which correctly uploaded image to site and I want to do exactly the same via curl
command.
import requests
url = 'http://1.2.3.4/upload'
files = {'image': open('foo.jpg', 'rb')}
params = {'bar': 'baz'}
requests.post(url, files=files, params=params)
# incorrect
curl -XPOST -F 'image=foo.jpg' -d 'bar=baz' 'http://1.2.3.4/upload'
I expect command like this will upload foo.jpg
with param baz
, but it seems to -F
is ignored by curl
when -d
is specified.
I want curl
with file name specified, rather than whole file data inside command like curlify
library does.
Upvotes: 0
Views: 191
Reputation: 50815
-F
and -d
together, former overrides the latter,@
sign,-F
implies -X POST
, and when it is used all data is sent as form-data, so bar=baz
will not be appended to URL as with -G
and -d
, you need to append it manually.curl -F '[email protected]' 'http://1.2.3.4/upload?bar=baz'
Upvotes: 1