19 #include <sys/types.h> 20 #include <boost/archive/iterators/binary_from_base64.hpp> 21 #include <boost/archive/iterators/transform_width.hpp> 31 return "SaveFileImageConnector";
51 std::chrono::seconds s = std::chrono::duration_cast< std::chrono::seconds >(std::chrono::system_clock::now().time_since_epoch());
52 std::string localDir = dir + std::string(
"/");
53 mkdir(localDir.c_str(),0777);
54 localDir += message->
group->
getName() + std::string(
"/");
55 mkdir(localDir.c_str(),0777);
56 localDir += std::to_string(s.count()) + std::string(
"/");
57 mkdir(localDir.c_str(),0777);
58 groupDir.insert(std::make_pair(message->
group,localDir));
59 step.insert(std::make_pair(message->
group,0));
63 groupDir.erase(message->
group);
64 step.erase(message->
group);
69 std::string payload( json_string_value( message->
payload ) );
73 const char* colon = strchr(payload.c_str(),
':');
78 const char* semicolon = strchr(colon,
';');
79 if (semicolon != NULL)
82 const char* comma = strchr(semicolon,
',');
87 int whole_length = strlen(comma);
89 uint8_t* temp_buffer = (uint8_t*)malloc(strlen(comma)+4);
91 using namespace boost::archive::iterators;
106 base64_dec src_it(comma);
107 for(; i < (whole_length+1)*3/4; ++i)
109 temp_buffer[i] = *src_it;
113 catch (dataflow_exception&)
116 std::string filename = groupDir.at(message->
group) + std::to_string(step.at(message->
group)++) + std::string(
".jpg");
117 FILE *fp = fopen(filename.c_str(),
"wb");
118 fwrite (temp_buffer ,
sizeof(
char), i, fp);
ImageBufferContainer * clientGetMessage()
errorCode clientSendMessage(ImageBufferContainer *message)
InsituConnectorGroup * group
errorCode init(int minport, int maxport)
SaveFileImageConnector(std::string dir)
pthread_mutex_t payload_mutex