Transfer a file to httpserver via POST command from curl

Chris Angelico rosuav at gmail.com
Sun Dec 22 12:24:22 EST 2019


On Mon, Dec 23, 2019 at 4:20 AM <musbur at posteo.org> wrote:
>
> On Wed, 18 Dec 2019 04:52:33 +1100
> Chris Angelico <rosuav at gmail.com> wrote:
>
> > On Wed, Dec 18, 2019 at 4:45 AM <musbur at posteo.org> wrote:
> > > BTW, the canonical way to upload files via http is PUT, not POST.
> > > You might want to look into that, but here it is off-topic.
> >
> > Citation needed.
>
> https://tools.ietf.org/html/rfc2616#page-55

Yes, that's the definition of PUT - but what does that mean in terms
of file uploads? POST is also valid. Look at its example usages.

> > Plenty of file uploads are done through POST
> > requests.
>
> Of course. Both work. It's just that the OP wanted to "upload a large
> binary file" using curl and in such cases I find that PUT can make for
> a cleaner, simpler interface.

Given that curl lets you specify any method for a request, I doubt
that PUT is going to be any cleaner or simpler.

> > Are you talking specifically about a RESTful API? Because
> > that's only one of many patterns you can follow.
>
> Sure. It's just that people sometimes aren't even aware of http
> methods besides GET and POST, and there's a chance for the OP
> to investigate this and maybe to find that PUT fits his needs better
> than POST in this case.

True, it's worth knowing about other HTTP methods. But stating that
PUT is "the canonical way to upload files" implies that what the OP is
doing is somehow violating the spec, which simply isn't true.

ChrisA


More information about the Python-list mailing list