小编GaJ*_*Jsu的帖子

是否可以在 Python 中的 Azure Function Linux Consumtion Plan 中保存临时文件?

首先对我的英语感到抱歉。我有一个使用 Python 的 Azure Function Linux Conuption Plan,我需要生成一个 html,使用 wkhtmltopdf 转换为 pdf 并通过电子邮件发送。

 #generate temporally pdf
config = pdfkit.configuration(wkhtmltopdf="binary/wkhtmltopdf")
pdfkit.from_string(pdf_content, 'report.pdf',configuration=config, options={})

#read pdf and transform to Bytes
with open('report.pdf', 'rb') as f:
    data = f.read()

#encode bytes
encoded = base64.b64encode(data).decode()

#Send Email
EmailSendData.sendEmail(html_content,encoded,spanish_month)
Run Code Online (Sandbox Code Playgroud)

代码在我的本地开发中运行正常,但是当我部署该函数并执行代码时,我收到一条错误消息:

Result: Failure Exception: OSError: wkhtmltopdf reported an error: Loading pages (1/6) [> ] 0% [======> ] 10% [==============================> ] 50% [============================================================] 100% QPainter::begin(): Returned false Error: Unable to write to destination
Run Code Online (Sandbox Code Playgroud)

我认为报告错误是因为出于某种原因无法获得写入权限。你能帮我解决这个问题吗?

提前致谢。

python permissions file save azure-functions

8
推荐指数
1
解决办法
7264
查看次数

标签 统计

azure-functions ×1

file ×1

permissions ×1

python ×1

save ×1