Skip to content

Instantly share code, notes, and snippets.

@wrparker
Created January 20, 2019 20:27
Show Gist options
  • Select an option

  • Save wrparker/efd770256cfd10fda46715b0f25ea543 to your computer and use it in GitHub Desktop.

Select an option

Save wrparker/efd770256cfd10fda46715b0f25ea543 to your computer and use it in GitHub Desktop.
indeed-atsdi.com python API consumption
import requests
import json
import ntpath
url = 'https://indeed-atsdi.com/api/get_upload_url'
file_names = ['current_version5.txt', 'file2.tsv']
API_KEY = 'XXXXXXXXX'
headers = {'Accept': 'application/json',
'Content-Type': 'application/json',
'token': API_KEY}
# This gets the presigned URLs
r = requests.post(url,
headers=headers,
json=json.dumps({'file_names': file_names}))
try:
r.raise_for_status()
urls = r.json()
# Upload file(s) to AWS.
for file_name in file_names:
with open(file_name, 'rb') as data:
upload_result = requests.put(urls[ntpath.basename(file_name)], data=data)
upload_result.raise_for_status()
except:
print (r.json())
print("Error occured.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment