|
@@ -246,9 +246,12 @@ void con_handler::handle_read_command(const boost::system::error_code &err,
|
|
// upload chunks
|
|
// upload chunks
|
|
|
|
|
|
// decode base64 string
|
|
// decode base64 string
|
|
- const std::string data = base64::decode(root["data"].asString());
|
|
|
|
|
|
+ const std::vector<char> data =
|
|
|
|
+ base64::decodeVector(root["data"].asString());
|
|
|
|
|
|
- this->putFile << data;
|
|
|
|
|
|
+ // write the vector data to the output file
|
|
|
|
+ std::ostream_iterator<char> output_iterator(putFile);
|
|
|
|
+ std::copy(data.begin(), data.end(), output_iterator);
|
|
|
|
|
|
// close file if put sends remaining = 0
|
|
// close file if put sends remaining = 0
|
|
if (root["remaining"].asInt() == 0) {
|
|
if (root["remaining"].asInt() == 0) {
|
|
@@ -385,9 +388,15 @@ void con_handler::handle_read_command(const boost::system::error_code &err,
|
|
size -= read;
|
|
size -= read;
|
|
int remaining = size / max_data_length +
|
|
int remaining = size / max_data_length +
|
|
(size % max_data_length == 0 ? 0 : 1);
|
|
(size % max_data_length == 0 ? 0 : 1);
|
|
|
|
+
|
|
|
|
+ // store binary data in vector because a string whould end with
|
|
|
|
+ // '\0'
|
|
|
|
+ std::vector<char> data;
|
|
|
|
+ data.assign(fileBuffer, fileBuffer + read);
|
|
|
|
+
|
|
answer["remaining"] = remaining;
|
|
answer["remaining"] = remaining;
|
|
answer["cancel"] = false;
|
|
answer["cancel"] = false;
|
|
- answer["data"] = base64::encode(fileBuffer);
|
|
|
|
|
|
+ answer["data"] = base64::encodeVector(data);
|
|
|
|
|
|
const std::string answerString =
|
|
const std::string answerString =
|
|
Json::writeString(stringBuilder, answer);
|
|
Json::writeString(stringBuilder, answer);
|