Good. Is this the correct way to do it? Basically it is a modification of
the program that I have been using for the JSON data. Here is the modified
code:

            string fileName = "..\\..\\test.jpg";

            string bucket = "images";

            byte[] buffer = File.ReadAllBytes(fileName);

            Debug.WriteLine("number of bytes read: " + buffer.Length);

 

            IRiakEndPoint cluster = RiakCluster.FromConfig("riakConfig");

            IRiakClient riakClient = cluster.CreateClient();

            RiakResult pingResult = riakClient.Ping();

            if (pingResult.IsSuccess)

            {

                RiakObject value = new RiakObject(bucket,

                                                  "1.jpg",

                                                  buffer,

 
RiakConstants.ContentTypes.ImageJpg,

 
RiakConstants.CharSets.Utf8);

                RiakResult<RiakObject> response = riakClient.Put(value);

                if (!response.IsSuccess)

                {

                    Debug.WriteLine(string.Format("Error ('{0}' - {1}:
Writing {2}",

                        response.ErrorMessage,

                        response.ResultCode,

                        "1.jpg"));

                }

            }

        }

 

From: Jeremiah Peschka [mailto:[email protected]] 
Sent: Thursday, March 14, 2013 4:57 PM
To: Kevin Burton
Cc: riak-users
Subject: Re: Binary data

 

How are you reading the JPEG and saving it to Riak? A code sample would be
lovely.

 

CorrugatedIron doesn't need a `--data-binary` option. All operations are
performed over the protocol buffers interface (barring several bucket
properties operations) - we don't alter any data that comes in to CI, we
just send and receive bytes on a socket. Much like curl, though, if you send
in junk data, CI is happily going to return that junk data back to you.




---

Jeremiah Peschka - Founder, Brent Ozar Unlimited

MCITP: SQL Server 2008, MVP

Cloudera Certified Developer for Apache Hadoop

 

On Thu, Mar 14, 2013 at 2:12 PM, Kevin Burton <[email protected]>
wrote:

I read on the FAQ how to get the same number of bytes as was stored:

When storing a non-text object like a PNG file in Riak and then retrieving
it with curl, it comes back a different size. For Example:

curl -i -X PUT --data @g005.PNG_L -H "Content-Type: image/png"
http://sfdev02:8098/luwak/g005.PNG_L

Curl will try to convert non-ASCII characters in PUT and POST bodies. Use
the --data-binary flag to turn this off:

curl -i -X PUT --data-binary @g005.PNG_L -H "Content-Type: image/png"
http://sfdev02:8098/luwak/g005.PNG_L

 

Is there an option like '-data-binary' for CorrugatedIron? I am 'put'ing
what should be binary data but if I retrieve the data with curl I get a
different size and if the binary data is a jpeg image it comes back as
corrupted?

 


_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

 

_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to