Created
April 27, 2013 21:48
-
-
Save ats/5474871 to your computer and use it in GitHub Desktop.
Command-line tool for browsing, downloading and uploading using the mover.io API. Requires a move.io account, a linked storage space (i.e. a "connector" such as Dropbox) and private user API keys available with the mover.io account.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# mover.rb | |
# general purpose utility for finding, getting and uploading files using the mover.io API. | |
# YAML config file is required in ~/.mover, contains API IDs and keys provided by mover.io. Example db.yaml: | |
# --- | |
# connector: mover_connector_ID | |
# app_id: mover_user_app_ID | |
# app_secret: mover_user_secret_key | |
# Directory: mover.rb config list [ID] | |
# Omit ID to show root level of connector | |
# $ mover.rb db list | grep testfile.txt | |
# file textfile.txt aVF2aBL | |
# Download: mover.rb config get remote_ID local_file | |
# $ mover.rb db get aVF2aBL testfile.txt | |
# Upload: mover.rb config put file destID | |
# Returns ID of uploaded file | |
# $ mover.rb db list | grep folder | |
# folder Textfiles QL53aJz | |
# $ mover.rb db put localfile.txt QL53aJz | |
# {"id":"LR321lfmAur"} | |
require 'rubygems' | |
require 'json' | |
require 'yaml' | |
def valid_json? json_ | |
JSON.parse(json_) | |
return true | |
rescue JSON::ParserError | |
return false | |
end | |
if !ARGV[0] | |
puts "No parameters provided, exiting.\n\n" | |
exit | |
end | |
config = ARGV[0] | |
home = `echo ~`.strip | |
auth = "#{home}/.mover/#{config}.yaml" | |
mover = YAML.load(File.read(auth)) | |
command = ARGV[1] | |
mover_auth = sprintf("-H 'Authorization: MoverAPI app_id=%s app_secret=%s'", mover["app_id"], mover["app_secret"]) | |
case command | |
when "get" | |
mover_req = sprintf("curl -s https://api.mover.io/connectors/%s/items/%s -X GET %s", mover["connector"], ARGV[2], mover_auth) | |
result = `#{mover_req}` | |
if valid_json? result | |
puts result | |
puts "(Possible bad remote file ID)\n" | |
else | |
File.open(ARGV[3], 'w') {|f| f.write(result) } | |
end | |
when "put" | |
mover_req = sprintf("curl -s https://api.mover.io/connectors/%s/collections/%s/items -X POST %s -F item=@\"%s\"", mover["connector"], ARGV[3], mover_auth, ARGV[2]) | |
if File.file?("#{ARGV[2]}") | |
result = `#{mover_req}` | |
puts result | |
else | |
puts "\nUpload file not found: #{ARGV[2]}\n" | |
end | |
when "list" | |
mover_req = sprintf("curl -s https://api.mover.io/connectors/%s/collections/%s -X GET %s", mover["connector"], ARGV[2], mover_auth) | |
result = `#{mover_req}` | |
if valid_json? result | |
parsed = JSON.parse(result) | |
inv = parsed["contents"] | |
inv.each do | item | | |
printf("%s\t%s\t%s\n", item["type"], item["name"], item["id"]) | |
end | |
else | |
puts "\nCollection ID not found: #{ARGV[2]}\n\n" | |
end | |
end |
They discontinued the public mover API several years ago. At that time I switched to a service called Kloudless, but I haven’t used it for years now, so I’m not sure if it’s still an effective replacement.
Mover itself works still nicely, just no API.
Guess I need to parse the HTML that the Browser return 😬
thanks for the quick Feedback 😁
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there
thank you for sharing.
Do you know if this still works now as mover was taken over by Microsoft?
I am trying to get more Information about the API but all end in 404. A support technician mentioned even that they do not offer direct API access any more