Send a POST request with some data, including a file, using Curl -
How can I include my file in the curl request form?
Below I need to add input to've got a POST request that includes data "first_name" and "last_name", but now I file. There are examples of where a person is only sending one file, but I am trying to send 1 or more files, and send other data.
curl H "Content-Type: application / json" -d '{first_name: "Donny", last_name:' P ', my_file: ???? } 'Https://sender.blockspring.com/api/blocks/319bfef4aad7f3477745048a2da3ae6a?api_key=2e0ef0c216078d60630d1321e67b243a
this can be done with a multipart is
manually a multipart construction is complicated, so maybe curl is a built-F option
Curl local host:. 8000 -f "my_file=@file.ext" -f "name = Daniel, last = P" -v curl man
F, --form (HTTP) This allows curl simulation in a filled form in which the user presses the submit button. It enables you to upload to force file name prefix with an @ sign for binary files, 'Content' section to a file in accordance with RFC 2388. The content type using multipart / form data Curl causes to post data. To get a piece of content from just one file, prefix the file name with the symbol. @ And & lt; Then it adds a file as a file upload to the post, while the & lt; Creates a text field and get the contents of that text field from that file.
Comments
Post a Comment