beast
beast copied to clipboard
Using http::file_body to POST from offset
How can I POST a file from a given offset? I will be using a serializer with file_body.
Use case: To restart a POST from where it was disconnected. The client would issue a HEAD and use the content-length value in the response as the offset to restart the POST from.
Is this possible?
Thanks. PS: Not necessarily a new Issue but looking for some guidance, if possible. Please point me to a mailing list if I should post there.
HI there @cgskumar77 , thanks for posting. If you would like interactive help, feel free to join us on the #beast channel of the cpplang slack https://cppalliance.org/slack/
Currently the file_body form of the serializer does not offer an offset argument. In order to achieve what you want, I would do the following:
- open the file and memory-map it
- use the dynamic_body type to describe the sub-region of the memory-mapped region to be sent.
You should be able to do that like this:
request<file_body> res(...);
boost::system::error_code ec;
res.body().file().seek(your_offset, ec);
See here
@cgskumar77 Did this work?
@cgskumar77 If that doesn't work, please reopen the issue.