The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
7.89k
stars
1.63k
forks
source link
nable to add both a file stream and key-value pairs to the body of the request simultaneously #1788
The C++ REST SDK does not provide a direct interface for creating multipart form data. I am unable to add both a file stream and key-value pairs to the body of the request simultaneously.
data << "--" << boundary << "\r\n"; data << "Content-Disposition: form-data; name=\"key\"\r\n\r\n" << pixkey << "\r\n"; data << "--" << boundary << "\r\nContent-Disposition: form-data; name=\"callback\"\r\n\r\n" << value << "\r\n"; data << "--" << boundary << "\r\nContent-Disposition: form-data; name=\"policy\"\r\n\r\n" << fdata.policy << "\r\n"; data << "--" << boundary << "\r\nContent-Disposition: form-data; name=\"Signature\"\r\n\r\n" << fdata.Signature << "\r\n"; data << "--" << boundary << "\r\nContent-Disposition: form-data; name=\"OSSAccessKeyId\"\r\n\r\n" << fdata.OSSAccessKeyId << "\r\n"; m_request.set_body(p.second, "multipart/form-data; boundary=" + boundary );
I would like to use both of the above methods to populate the body simultaneously. I want to retrieve the file using a stream instead of converting it into a string and placing it in a key-value pair. How can I put the stream data into a key-value pair?read_entire_file(strm.first) is the std::string of file.
data << "--" << boundary << "Content-Type: application/octet-stream\r\n\r\n" << read_entire_file(strm.first) << "\r\n\r\n";
The C++ REST SDK does not provide a direct interface for creating multipart form data. I am unable to add both a file stream and key-value pairs to the body of the request simultaneously.
`http_client client(U("http://example.com"));
data << "--" << boundary << "\r\n"; data << "Content-Disposition: form-data; name=\"key\"\r\n\r\n" << pixkey << "\r\n"; data << "--" << boundary << "\r\nContent-Disposition: form-data; name=\"callback\"\r\n\r\n" << value << "\r\n"; data << "--" << boundary << "\r\nContent-Disposition: form-data; name=\"policy\"\r\n\r\n" << fdata.policy << "\r\n"; data << "--" << boundary << "\r\nContent-Disposition: form-data; name=\"Signature\"\r\n\r\n" << fdata.Signature << "\r\n"; data << "--" << boundary << "\r\nContent-Disposition: form-data; name=\"OSSAccessKeyId\"\r\n\r\n" << fdata.OSSAccessKeyId << "\r\n"; m_request.set_body(p.second, "multipart/form-data; boundary=" + boundary );
I would like to use both of the above methods to populate the body simultaneously. I want to retrieve the file using a stream instead of converting it into a string and placing it in a key-value pair. How can I put the stream data into a key-value pair?read_entire_file(strm.first)
is the std::string of file.data << "--" << boundary << "Content-Type: application/octet-stream\r\n\r\n" << read_entire_file(strm.first) << "\r\n\r\n";