9

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

Jakub Roztocil
  • 15,930
  • 5
  • 50
  • 52
MaatDeamon
  • 9,532
  • 9
  • 60
  • 127

1 Answers1

22

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
Jakub Roztocil
  • 15,930
  • 5
  • 50
  • 52