Is Possible To Save A Temporaly File In A Azure Function Linux Consuption Plan In Python?
first of all sorry for my English. I have an Azure Function Linux Consuption Plan using Python and I need to generate an html, transform to pdf using wkhtmltopdf and send it by ema
Solution 1:
The tempfile.gettempdir()
method returns a temporary folder, which on Linux is /tmp
. Your application can use this directory to store temporary files generated and used by your functions during execution.
So use /tmp/report.pdf
as the file directory to save temporary file.
withopen('/tmp/report.pdf', 'rb') as f:
data = f.read()
For more details, you could refer to this article.
Solution 2:
Final correct code:
config = pdfkit.configuration(wkhtmltopdf="binary/wkhtmltopdf")
local_path = os.path.join(tempfile.gettempdir(), 'report.pdf')
logger.info(tempfile.gettempdir())
pdfkit.from_string(pdf_content, local_path,configuration=config, options={})
Post a Comment for "Is Possible To Save A Temporaly File In A Azure Function Linux Consuption Plan In Python?"