0

convertapiAWS Lambdaにデプロイする必要があります。

Pythonで試しimport convertapiてみると、インポートする必要があるため機能しません。

AWS では、ローカル フォルダーまたは ARN を使用してライブラリをデプロイします。

https://github.com/keithrozario/Klayers/blob/master/deployments/python3.7/arns/eu-west-3.csvconvertapiのような利用可能な ARN はありますか?

そうでない場合、実行できるようにするには、ラムダでどのフォルダーをコピー/貼り付けする必要がありますimport convertapiか?

4

1 に答える 1

0

これは、ConvertAPI ライブラリを使用しない Python の例です。

`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
于 2022-01-25T14:41:25.143 に答える