Ruby

Control Rclone from Ruby using the remote control HTTP API with Net::HTTP.

Ruby's standard library includes Net::HTTP, which is enough to call Rclone's remote control API without installing a gem.

Usage

Net::HTTP.get sends a GET request to the root of the API and returns the body as a string, which the sample prints:

require 'net/http'
require 'uri'
require 'json'

uri = URI.parse('http://localhost:5572/')
response = Net::HTTP.get(uri)
puts response

Making a POST request:

require 'net/http'
require 'uri'
require 'json'

uri = URI.parse('http://localhost:5572/core/stats')
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.path, { 'Content-Type' => 'application/json' })
request.body = {}.to_json
response = http.request(request)
puts response.body

How is this guide?

On this page