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".
<code>
{ok,O} = riakc_pb_socket:put(C, riakc_obj:new(<<"b">>, <<"k">>, <<"data">>,
<<"text/plain">>), [return_body]).
riakc_obj:get_content_type(O).
</code>
After applying next patch to riakc_obj.erl, the code above works as expected
(you should use "text/plain" string instead of binary).
<patch>
@@ -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)}.
</patch>
Also because of problems with updating metadata without updating value the
update_content_type
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.
--
Mikl
--
View this message in context:
http://riak-users.197444.n3.nabble.com/Setting-content-type-with-Erlang-PBC-tp845155p845155.html
Sent from the Riak Users mailing list archive at Nabble.com.
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com