Project

General

Profile

Wt::Http::Client and uploading files?

Added by jeroen smeenk about 4 years ago

I'm trying to get rid of curl and use Wt::Http::Client instead. Is it possible to upload files with a POST request?

As far as I can see there is just a body text and key value pairs in the header list.

I'm running a Wt::WResource that simply logs everything received in handleRequest();

With the following command line I can get a file into the request.uploadedFiles()

curl 'http://localhost/Debug' -F file=@

Is it possible to create the same request with Wt::Http::Client::request() ??


Replies (1)

RE: Wt::Http::Client and uploading files? - Added by Roel Standaert about 4 years ago

I think while it is possible to put a file into the body text, I don't think Wt::Http::Client currently supports encoding a file as form data, like a normal file upload would do.

You could of course write the body in the correct format yourself and do it that way, but it's not something that Wt can do for you.

Are you sending requests from Wt to Wt? Because in that case I would just put the data in the body. That's actually a more efficient way of transferring a file.

    (1-1/1)