Kevin,

Please take a look at this sample application:

https://github.com/DistributedNonsense/CorrugatedIron.ImageStore

I've just thrown it together for you. It is a sample Winforms application
which shows how to store and retrieve image data using CorrugatedIron. It's
not a production application by any means, but it does demonstrate how to
do what you're trying to do. All the images that are stored in Riak using
this sample application are accessible via cURL and render correctly. So if
you store an image, you should be able to use any other client to pull the
image down and view it in an image viewer.

The one thing to note is that in your code you were specifying a character
set of UTF8, which isn't correct for binary data.

Please take a look at the application and its source, it will show you what
to do.

HTH.
OJ

On Fri, Mar 15, 2013 at 8:28 AM, Kevin Burton <[email protected]>wrote:

> I know that if I specify an incorrect content type such as
> application/json for the binary data then I get close to 6MB back so there
> is some interpretation. ****
>
> ** **
>
> *From:* Kevin Burton [mailto:[email protected]]
> *Sent:* Thursday, March 14, 2013 5:16 PM
> *To:* 'Jeremiah Peschka'
> *Cc:* 'riak-users'
> *Subject:* RE: Binary data****
>
> ** **
>
> 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]<[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
>
>


-- 

OJ Reeves
+61 431 952 586
http://buffered.io/
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to