尝试过:
可能性:
-当我从 s3 获取文档文件时,在浏览器 JS 中将其转换为 PDF。- 以某种方式修复部署包中的 comtypes 或 win32com。正在使用Python 3.6。
import json
import urllib
import boto3
from boto3.s3.transfer import TransferConfig
from botocore.exceptions import ClientError
import lxml
import comtypes.client
import io
import os
import sys
import threading
from docx import Document
def lambda_handler(event, context):
bucket = event['Records'][0]['s3']['bucket']['name']
key = urllib.parse.unquote_plus(event['Records'][0]['s3']['object']['key'], encoding='utf-8')
try:
response = s3.get_object(Bucket=bucket, Key=key)
# Creating the Document
f = io.BytesIO(response['Body'].read())
document = …Run Code Online (Sandbox Code Playgroud)