Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload a file with PUT in HTTPie

I'm searching for the syntax to write a PUT operation that upload a file with HTTPie. Please could you point me to the right syntax ? I could not find a way to do so on the official documentation

like image 961
MaatDeamon Avatar asked Jun 13 '18 06:06

MaatDeamon


1 Answers

To achieve this with httpie, you need to do two things:

  1. Set the HTTP method to PUT, which is trivial: $ http PUT […]
  2. Pass the contents of the file, for which there are various ways:

Redirected input:

$ http PUT httpbin.org/put Content-Type:image/png < /images/photo.png

Request data from a filename (automatically sets the Content-Type header):

$ http PUT httpbin.org/put @/images/photo.png

Form file upload:

$ http --form PUT httpbin.org/put photo=@/images/photo.png
like image 66
Jakub Roztocil Avatar answered Sep 30 '22 17:09

Jakub Roztocil