Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'rest-client'
- require 'json'
- scheme="https"
- hostname="yourdomain.com/api/v3"
- username="myuser"
- password="supersecure"
- file = "foo.txt"
- payload = nil
- File.open(file, "r") do |f|
- payload = {
- :description => "test",
- :public => false,
- :files => {
- "foo.txt" => {
- :content => f.read
- }
- }
- }
- end
- RestClient.post("#{scheme}://#{username}:#{password}@#{hostname}/gists", payload.to_json, :content_type => "text/json")
Add Comment
Please, Sign In to add comment