0

I need to deploy convertapi on an AWS Lambda.

If I try import convertapi with python, it doesn't work because I need to import it.

In AWS, we use local folder or ARN to deploy libraries.

Is there an available ARN for convertapi like in https://github.com/keithrozario/Klayers/blob/master/deployments/python3.7/arns/eu-west-3.csv ?

If not, which folder should I copy/paste in my lambda to be able to do import convertapi ?

Utopion
  • 935
  • 1
  • 4
  • 15
  • Why just use HTTP Post and skip library? What ConvertAPI endpoint do you use? – Tomas Jan 25 '22 at 13:34
  • Looks like it's better to use http, I tried but I didn't suceed in less than 1 hour, I'm gonna continue with the import for the moment. – Utopion Jan 25 '22 at 14:17

1 Answers1

0

This is an example in Python without using ConvertAPI library.

`requests` library is required to run this example.

It can be installed using
> pip install requests

or if you are using Python 3:
> pip3 install requests
'''

import requests
import os.path
import sys

file_path = './test.docx'
secret = 'Your secret can be found at https://www.convertapi.com/a'

if not os.path.isfile(file_path):
    sys.exit('File not found: ' + file_path)

url = 'https://v2.convertapi.com/convert/docx/to/pdf?secret=' + secret
files = {'file': open(file_path, 'rb')}
headers = {'Accept': 'application/octet-stream'}

response = requests.post(url, files=files, headers=headers)

if response.status_code != 200:
    sys.exit(response.text)

output_file = open('result.pdf', 'wb') 
output_file.write(response.content)
output_file.close
Tomas
  • 17,551
  • 43
  • 152
  • 257