Image file upload in CDMI

134 views
Skip to first unread message

pvg pvg

unread,
Feb 6, 2013, 9:30:29 PM2/6/13
to snia-...@googlegroups.com
I am using CDMI version 1.0.1. I want to know that how to upload an image file on CDMI.For that what should be assigned to "value".Also I want to know,How to update CDMI version? I want to shift to version 1.0.2.
Thanks

Nikhil

unread,
Mar 26, 2013, 4:53:20 AM3/26/13
to snia-...@googlegroups.com
Hi Appa,

I have also installed SNIA CDMI RI although i have hte version 1.0.2. I am able to PUT text file son my CDMI server but i want to put images, etc. in my CDMI server. If you could get this functionality working for you can you please help me by letting me know how exactly to upload an image in CDMI server. I tried out putting image paths for the "value" filed and changed the mimetype as "image/JPEG" but it is throwing the following error:

ETag: "Object PUT Error : org.codehaus.jackson.JsonParseException: Unrecognized character escape 'U'

Also if anyone has tried to PUT objects (text files, images, etc.) using curl command then please do let me know the syntax for the same.

Thanks & Regards,
Nikhil
Message has been deleted

sudhagar

unread,
Apr 9, 2013, 10:22:45 AM4/9/13
to snia-...@googlegroups.com
Hi appa,
You can upload the image files by encoding them to base64.
Try the following code in the client program. Also you have got
to decode it in the server before the value is written to the file.
            byte arr[] = Files.toByteArray(new File(
                    "/home/cloudibm2/Desktop/s1_ObjectCreate.png"));
            byte encoded1[] = Base64.encodeBase64(arr);
            String b64 = new String(encoded1);
            String value = org.codehaus.jettison.json.JSONObject.quote(b64);
            ...
            ...
            String respStr = "{\n";
            respStr = respStr + "\"mimetype\" : \"" + "text/plain" + "\",\n";
            respStr = respStr + "\"value\" : " + value + "\n";
            respStr = respStr + "}\n";
Reply all
Reply to author
Forward
0 new messages