Guest User

Untitled

a guest
Oct 6th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. require 'rubygems'
  2. require 'rest-client'
  3. require 'json'
  4.  
  5. scheme="https"
  6. hostname="yourdomain.com/api/v3"
  7. username="myuser"
  8. password="supersecure"
  9.  
  10. file = "foo.txt"
  11. payload = nil
  12. File.open(file, "r") do |f|
  13. payload = {
  14. :description => "test",
  15. :public => false,
  16. :files => {
  17. "foo.txt" => {
  18. :content => f.read
  19. }
  20. }
  21. }
  22. end
  23.  
  24. RestClient.post("#{scheme}://#{username}:#{password}@#{hostname}/gists", payload.to_json, :content_type => "text/json")
Add Comment
Please, Sign In to add comment