In my .net core web API , I'm using OpenHtmlToPdf nuget package for rendering HTML documents to PDF format. The implementation working fine locally but not in the server production K8 environment. I'm getting following message from the logs.
Permission denied
I did several workaround and was able to find out, a lib called OpenHtmltoPdf
uses Path.GetTempPath()
and Guid.NewGuid()
to create a temp file. seems above permission denied error occurs when it trying to access that temp path. this is code snippet from the OpenHtmltoPdf
lib. OpenHtmlToPdf git repo
//inside TemporaryPdf class
public static string TemporaryFilePath()
{
return Path.Combine(Path.GetTempPath(), "OpenHtmlToPdf", TemporaryPdf.TemporaryFilename());
}
private static string TemporaryFilename()
{
return Guid.NewGuid().ToString("N") + ".pdf";
}
I just added following line to my application to determine the temp path and its returns File Path is: /tmp/
.
Console.WriteLine("File path is:" + Path.GetTempPath());
But in the Kubernetes pods have rwx
permissions for /tmp/
folder for the all users.
My problem is, after deploying the API, do the NuGet packages use a separate temp path? So how exactly identify it?