Skip to content

Instantly share code, notes, and snippets.

@Ferdev
Created January 30, 2013 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ferdev/4672376 to your computer and use it in GitHub Desktop.
Save Ferdev/4672376 to your computer and use it in GitHub Desktop.
require 'httmultiparty'
file = File.open('/path/to/your/file.zip')
response = HTTMultiParty.post('https://your_user.cartodb.com/api/v1/imports', :query => {:file => file, :api_key => 'your_api_key'})
upload_result = JSON.parse(response.body)
# loop until you get {'sucess': 'true'} from the next request
success = false
until success do
response = HTTParty.get("https://your_user.cartodb.com/api/v1/imports/#{upload_result['item_queue_id']}", :query => {:api_key => 'your_api_key'})
success = JSON.parse(response.body)['success'] == 'true'
end
source "https://rubygems.org"
gem 'httmultiparty'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment