For a quick upload to a server that accepts PUT, I do not need a form or a client. curl -T sends the file as it is.
-T (--upload-file) sends a local file to the URL you give. With an HTTP or HTTPS URL the manual says it uses the PUT method:
curl -T backup.tar.gz https://example.com/uploads/
Note the slash at the end. If the URL has no file part, curl appends the local file name to it, so this stores the file as /uploads/backup.tar.gz. The manual says you must use a trailing slash on the last directory, otherwise curl thinks that last name is the remote file name and uploads to exactly that. Forgetting the slash can therefore overwrite something.
A few more forms from the manual:
-T -reads from standard input, sotar czf - /data | curl -T - https://example.com/uploads/data.tgzstreams an archive without a temporary file. With a pipe there is no file name to append, so give the full name in the URL.- The argument can be globbed, as in
curl --upload-file "{file1,file2}" https://example.com/uploads/. - Each
-Tgoes with one URL. For several URLs, repeat the pair.
The caveat is that PUT is only half of the story: the server has to be set up to accept it. Many web servers answer a PUT with an error unless someone enabled uploads, and for most apps an API with a token or a -F form upload is the real route. Add --fail-with-body so that a refusal shows up in your script as an error with the server’s message instead of passing quietly.
The manual also mentions that for FTP or SFTP URLs the same option uploads the file, which is handy for a one-off copy to a box that only offers one of those.
Further reading: curl man page: –upload-file