How Can I Post Files and JSON Data Together With Curl?

前端 未结 4 1163
别那么骄傲
别那么骄傲 2021-02-19 03:30

I\'ve been posting a file with this curl command:

curl -i -F file=@./File.xlsm -F name=file -X POST http://example.com/new_file/

Now I want to

4条回答
  •  南方客
    南方客 (楼主)
    2021-02-19 03:33

    From @nbrooks comment, adding an additional header HTTP header works fine as shown below by using several -H or --header flags to your curl command:

    
    curl -H "comment: Submitting a new data set." -H  "current: false" -H "sheet: 1" -H "row: 7" -F file=@./File.xlsm -F name=file http://example.com/new_file/
    

    comment and current can be combined into "metadata" in the request.headers processing part on the flask web server.

提交回复
热议问题