thorpedosg

Untitled

Aug 6th, 2018
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require 'riak'
  2.  
  3. @host = ARGV[0]
  4. @port = ARGV[1].to_i
  5. @bucket = ARGV[2]
  6. @dir = ARGV[3]
  7.  
  8. @riak_client = Riak::Client.new(:host => @host, :http_port => @port)
  9.  
  10. @riak_bucket = @riak_client.bucket(@bucket)
  11. Dir.glob(@dir + '/*.json') do |file_path|
  12. json = File.read(file_path)
  13.  
  14. w_props = {
  15. :w => 0,
  16. :dw => 0,
  17. :returnbody => false
  18. }
  19.  
  20. o = @riak_bucket.new(File.basename(file_path, ".json"))
  21. o.data = json
  22. o.content_type = 'application/json'
  23. o.store(w_props)
  24. end
Add Comment
Please, Sign In to add comment