Skip to main content

Hi folks, this one is stumping me - I have a file created in G-Suite in a Zap step and want to then upload this to a s3 site using some Python code (and then link to a database).

When I test the code, I get an error:

Traceback (most recent call last): File "<string>", line 18, in the_function FileNotFoundError: [Errno 2] No such file or directory: 'https://docs.google.com/feeds/download/documents/export/Export?id=1-Oht6-vzbYIpC5gq4rPpS83zYu

Here’s the input and the code (API Key redacted):

 

Input Data

ID : de685b16-7119-432a-8298-d919a0c3d15c

REFFILE : Ref1_file

FILE : https://docs.google.com/feeds/download/documents/export/Export?id=1-Oht6-vzbYIpC5gq4rPpS83zYu10JfAuxvJotULLevg&exportFormat=pdf

 

Code

import json

import xml.etree.ElementTree

import mimetypes

import os

import requests

 

HOST="ceracare.fountain.com/api"

API_KEY="REDACTED"

APPLICANT=input_data_'ID']

FILENAME=input_data_'FILE']

 

UPLOAD_FILE=(FILENAME, open(FILENAME, 'rb'), mimetypes.guess_type(FILENAME)E0])

UPLOAD_KEY=input_datat'REFFILE']

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_jsons'form_data']

form_datar'Content-type'] = ""

 

s3_upload_response = requests.post(upload_response_jsonn'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, data=finish_upload_data)

print(finish_upload_response)

Hi @PeterCera 

Is there a reason you are not using the AWS S3 Zap app?

 


Hi @Troy Tessalone thanks - thanks for this. Yes, the reason were not using the AWS app is that the specific AWS location subsequent file linkage is not on our own S3 but part of a cloud SaaS provider system called Fountain (our recruitment platform). They have a specific way of uploading and linking files which they have provided the above python script for. I’m mostly confused that using the FILE url directly serves me the pdf, but in the script is not recognised. I’ll try discussing direct access to S3 but doubt I’ll get it.