Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for upload binary data via cpp bindings #696

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sasokol
Copy link

@sasokol sasokol commented Mar 11, 2016

I created a new constructor with data size.

@bioothod
Copy link
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
Copy link
Author

sasokol commented Mar 11, 2016

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;
....
}

@@ -342,10 +342,15 @@ class argument_data_base
}

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

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
Copy link

shindo commented Mar 11, 2016

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
Copy link
Author

sasokol commented Mar 11, 2016

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