Uploading a file to a Boost Beast Server

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Uploading a file to a Boost Beast Server

Boost - Users mailing list
I am using Beast 277 and code from the advanced server example as the
basis for my own one. As part of the functionality I need to allow
users the ability to upload a file to the server via their browser. So
I had a look at the 'Deferred Body Type' in the examples provided but
I can't see how I can make use of it in my own server, although I have
tried but fall foul of the SyncReadStream.

Is there a working example anywhere of how I can capture and save a
file uploaded to the server by a user please.
--
Bill
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Uploading a file to a Boost Beast Server

Boost - Users mailing list
On Mon, Mar 23, 2020 at 8:05 AM Bill Moo via Boost-users
<[hidden email]> wrote:
> Is there a working example anywhere of how I can capture
> and save a file uploaded to the server by a user please.

I don't think there's an example, but it is as easy as:

    http::request<http::string_body> req;
    http::read( sock, buf, req );

When the read returns, `res.body()` will hold the contents of the uploaded file.

Thanks
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Uploading a file to a Boost Beast Server

Boost - Users mailing list
Thanks, I'll check it out and if anyone should know it will be
yourself. :-) Thank you for your time.
--
Bill

On Mon, 23 Mar 2020 at 16:22, Vinnie Falco <[hidden email]> wrote:

>
> On Mon, Mar 23, 2020 at 8:05 AM Bill Moo via Boost-users
> <[hidden email]> wrote:
> > Is there a working example anywhere of how I can capture
> > and save a file uploaded to the server by a user please.
>
> I don't think there's an example, but it is as easy as:
>
>     http::request<http::string_body> req;
>     http::read( sock, buf, req );
>
> When the read returns, `res.body()` will hold the contents of the uploaded file.
>
> Thanks
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users