IDrive - EVS - REST API - uploadFile
#!/usr/bin/eruby
<%
require "net/https"
require 'uri'
require 'rexml/document'
base_url = "[API URL retrieved from previous getServerAddress call]"
uid = "[your IDrive user name]"
pwd = "[your IDrive password]"
uri = URI.parse("https://" + base_url)
http = Net::HTTP.new(uri.host, uri.port)
filepath = "[local path to file your uploading]"
filename = "[local file name]"
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new("/evs/uploadFile")
request['content-type'] = "multipart/form-data"
file = File.open(filepath, "rb")
parameters = {}
parameters['uid'] = uid
parameters['pwd'] = pwd
parameters["file[new_file]"] = file
parameters["file[filename]"] = filename
request.set_form_data(parameters)
response = http.request(request)
puts response
%>