post
https://api.fountain.com/v2/applicants//secure_documents/link_upload
Step 2 of 2 for adding files to an applicant profile.
Recent Requests
Log in to see full request history
| Time | Status | User Agent | |
|---|---|---|---|
Retrieving recent requests… | |||
Loading…
This is Part 2 to adding files to an applicant's profile. Please refer to File Upload to S3 for Part 1.
"Key" ClarificationNot to be confused by S3's Object 'Key', the
keyrefers to Fountain's identifier for the file you're uploading. In the Product, this is known as "Data Key". The S3 Object Key is passed in ass3_key.
We recommend using the same key for similar files you're collecting from applicants to prevent the creation of duplicate data keys. Example, if all your applicants have a resume, upload all the resume files as resume_file.
import json
import xml.etree.ElementTree
import mimetypes
import os
import requests
HOST="api.fountain.com"
API_KEY="K-9NB9DkxU7NdrB9eRBHCA"
APPLICANT="6d0d9434-2817-4b96-9ad4-e33a7f2a0adb"
FILENAME="dog.jpg"
UPLOAD_FILE=(FILENAME, open(FILENAME, 'rb'), mimetypes.guess_type(FILENAME)[0])
UPLOAD_KEY="test"
UPLOAD_URL="https://%s/v2/applicants/%s/secure_documents/upload" % (HOST, APPLICANT)
LINK_UPLOAD_URL="https://%s/v2/applicants/%s/secure_documents/link_upload" % (HOST, APPLICANT)
HEADERS = { 'X-ACCESS-TOKEN': API_KEY }
upload_response = requests.post(UPLOAD_URL, headers=HEADERS)
upload_response_json = json.loads(upload_response.text)
form_data = upload_response_json['form_data']
form_data['Content-type'] = ""
s3_upload_response = requests.post(upload_response_json['url'], data=form_data, files={'file': UPLOAD_FILE})
s3_upload_response_xml = xml.etree.ElementTree.fromstring(s3_upload_response.text)
s3_filename = s3_upload_response_xml.find("Key").text
finish_upload_data = {
'key': UPLOAD_KEY,
's3_key': s3_filename,
'size': os.path.getsize(FILENAME),
}
finish_upload_response = requests.post(LINK_UPLOAD_URL, headers=HEADERS, json=finish_upload_data)
print(finish_upload_response)