install multipart-post require 'rubygems' require 'json' require 'net/https' require 'net/http/post/multipart' url = URI.parse("https://api.kraken.io/file") uploadfile = {:name =>'/Path/To/File.jpg'} auth = { "user" => "your-kraken-username", "pass" => "your-kraken-password", "apikey" => "your-kraken-api-key" }.to_json File.open(uploadfile[:name]) do |file| req = Net::HTTP::Post::Multipart.new url.path, "auth" => auth, "file" => UploadIO.new(file, 'logotyp.png') https = Net::HTTP.new(url.host, url.port) https.use_ssl = true res = https.start() {|conn| conn.request(req)} response = JSON.parse(res.body) if response['success'] puts 'Success. Optimized image URL: ' + response['krakedURL'] else puts 'Fail. Error message: ' + response['error'] end end Thursday, October 10, 13