[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Transfer a file to httpserver via POST command from curl

On Fri, Dec 13, 2019 at 3:44 AM Karthik Sharma <karthik.sharma at gmail.com> wrote:
> I am doing a POST using curl as follows.
> curl -X POST --data-binary @/home/user/testfile.txt http://
> Is it really possible to transfer a large binary file from my machine to
> the above httpserver via POST command and download it again? If yes, is the
> above Flask app enough for that and what am I doing wrong?

I think your Flask code is okay (haven't checked in detail, but at
first glance it looks fine), but for file uploads to be recognized in
request.files, you'll need to change the way you run curl.

Try this:

curl -F 'file=@/home/user/testfile.txt'

The word "file" in there ends up as the key in request.files (so if
you used "spam=", you'd get request.files["spam"]), and you can add
other form data as well if you choose.