Riak3.2.0 ,using Post-commit
baoxiangwei opened this issue · comments
This Riak version is 3.2.0, using Post-commit hook .
This is my erlang code:
-module(post_commit).
-export([post/1]).
post(Object) ->
Path="/home/firefly/riak_new/riak_3.20/riak/rel/riak/test.sh",
KeyName = riak_object:key(Object),
io:format("Key name: ~s~n", [KeyName]),
BucketName = riak_object:bucket(Object),
io:format("Bucket name: ~p~n", [BucketName]),
Value = riak_object:get_value(Object),
io:format("Object value: ~p~n", [Value]),
Command= io_lib:format("sh ~s ~s ~s ~n", [Path, [KeyName], [BucketName]]),
io:format("Command value: ~s~n", [Command]),
Output = os:cmd(Command),
io:format("~s~n", [Output]).
when I add some data into a bucket,
curl -XPUT http://localhost:8098/types/my_bucket_type/buckets/some-bucket/keys/babbbvv -H "Content-Type: application/json" -d '{"name": "John Smith", "age": 42, "email": "john.smith@example.caa1111odd9911m"}'
I can only get the key name "babbbvv " , but I can not get the bucket name "some-bucket".
But if i use "riak remote_console", enter the erlang shell , Input this code:
Bucket = <<"my_bucket">>,
Key = <<"my_key">>,
ContentType = <<"text/plain">>,
Data = <<"hello world">>,
Object = riak_object:new(Bucket, Key, Data, [{<<"content-type">>, ContentType}]),
post_commit:post(Object).
I can get not only this key name "my_key", but also the bucket name "my_bucket".