Setting content-type with Erlang PBC.

Mikl Kurkov mkurkov at
Wed May 26 11:30:30 EDT 2010

It seems that Erlang PBC has another issue with content-type setting.

There is inconsistency of types of content-type value in riakc_obj module
and riakc_pb.
The riakc_obj assumes it binary while riakc_pb waiting for string.

Because of that next code returns undefined while it definitely should
return "text/plain".
 {ok,O} = riakc_pb_socket:put(C, riakc_obj:new(<<"b">>, <<"k">>, <<"data">>,
<<"text/plain">>), [return_body]).

After applying next patch to riakc_obj.erl, the code above works as expected
(you should use "text/plain" string instead of binary).
@@ -176,7 +176,7 @@
 -spec update_content_type(#riakc_obj{}, metadata()) -> #riakc_obj{}.
 update_content_type(Object=#riakc_obj{}, CT) ->
     M1 = get_update_metadata(Object),
-    Object#riakc_obj{updatemetadata=dict:store(?MD_CTYPE,
riakc_pb:to_binary(CT), M1)}.
+    Object#riakc_obj{updatemetadata=dict:store(?MD_CTYPE, CT, M1)}.

Also because of problems with updating metadata without updating value the
function doesn't work too. The only way to update content-type is by using
update_value/3 function.

I think it is not very convienient to use different types for content-type
and other metadata values.
Maybe it would be better to stick with binaries for all of metadata values.

View this message in context:
Sent from the Riak Users mailing list archive at

More information about the riak-users mailing list