Skip to content

fix for upload binary data via cpp bindings - #696

Open
sasokol wants to merge 1 commit into
reverbrain:masterfrom
sasokol:master
Open

fix for upload binary data via cpp bindings#696
sasokol wants to merge 1 commit into
reverbrain:masterfrom
sasokol:master

Conversation

@sasokol

@sasokol sasokol commented Mar 11, 2016

Copy link
Copy Markdown

I created a new constructor with data size.

@bioothod

Copy link
Copy Markdown
Member

Looks good to me, but it requires a test, please add one which calls some method with binary data and results you read back is invalid for current code and works good with your new code.

@sasokol

sasokol commented Mar 11, 2016

Copy link
Copy Markdown
Author

Example:

...
char *data;
elliptics_client.write_prepare(key, "", 0,total);
uint64_t  chunk = buflen;
while ( length > 0 ) {
   ...
   if ( chunk > length ){
       chunk = length;
   } 

   FCGX_GetStr(data, chunk, request.in); // get a chunk of data from socket
   // argument_data file( data ); // In the storage bad data. But if I send to the socket a base64 encoded data then its's ok.
   argument_data file( data, chunk ); // This I use the fix.
   async_result = elliptics_client.write_plain(key, file, offset); //write the chunk into elliptick session
   offset += chunk;
....
}


argument_data_base(const char *data) :
m_data(pointer_type::from_raw(const_cast<char *>(data), std::strlen(data)))
m_data(pointer_type::from_raw(const_cast<char *>(data), std::strlen(data))) // It isn't correct for binary data.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// It isn't correct for binary data.

This comment is unnecessary as the constructor is not about binary data.

@shindo

shindo commented Mar 11, 2016

Copy link
Copy Markdown

The pull request is not "fix" actually, as there's no bug. You just added "helper" constructor for binary data.

Without the "fix" you can already use the constructor from data_pointer_base:

argument_data file(argument_data::pointer_type::from_raw(data, chunk));

@sasokol

sasokol commented Mar 11, 2016

Copy link
Copy Markdown
Author

OK, thank you. It works...
I not found the in docs and did not understand the headers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants