Google App Engine Flexible Environment tmp folder is not writable

2,162 views
Skip to first unread message

Dhandapani Sattanathan

unread,
Feb 1, 2018, 1:09:10 AM2/1/18
to Google App Engine
Hi,

I m using more than 1 years Google App engine Flexible Environment. 

My Application used mpdf API using PHP.The latest version of mpdf changed dynamically create temp folder for font creation and image.

In my Development server This one working fine.

But When I use Google App Engine Flexible environment, I got this error "PHP message: PHP Fatal error: Uncaught Mpdf\MpdfException: Temporary files directory "/app/web/mpdf/vendor/mpdf/mpdf/src/Config/../../tmp" is not writable in /app/web/mpdf/vendor/mpdf/mpdf/src/Cache.php:23"

This is not mpdf issue. I dont know How to give write permission for this tmp folder in Google App engine Flexible Environment.

You can see my sample here with detailed log.

Plz help me how to solve this?

Is it possible can use the latest mpdf in GAE FE?

Thanks,
SN

Kenworth (Google Cloud Platform)

unread,
Feb 1, 2018, 11:26:07 AM2/1/18
to google-a...@googlegroups.com
Directories for temporary files are documented on this mPDF Manual. Note that mPDF library is not a Google product and we therefore can not support it due to our limited visibility. It is recommended to continue technical support for this tool on Stack Overflow and/or on their official support forum. After a quick courtesy search I was able to discover this similar StackOverflow thread that offers multiple insights about a possible solution.

Shaharia Azam

unread,
Feb 1, 2018, 6:45:28 PM2/1/18
to Google App Engine
Did you try changing the temporary path with "/tmp"? This "/tmp" should be writable or use php sys_get_temp_dir() function in your GAE flexible environment so you will get a temporary directory file location that is writable.

Dhandapani Sattanathan

unread,
Feb 2, 2018, 12:48:41 AM2/2/18
to Google App Engine
Thanks, Kenworth & Shaharia Azam for your reply.


I tried with sys_get_temp_dir() function in GAE Flexible Environment, 

I changed like index.php and Cache.php in Mpdf. Now /tmp writable in GAE FE.

index.php

<?php


require_once
'mpdf/vendor/autoload.php';
use Mpdf\Mpdf;


$path
=sys_get_temp_dir ();
putenv
('MPDF_TEMP_PATH='.$path);


?>



I did modification in mpdf Cache.php

public function __construct($basePath, $cleanupInterval = 3600)
 
{
 $basePath
=getenv('MPDF_TEMP_PATH');
 
if (!is_writable($basePath)
 
&& is_writable(dirname($basePath))
 
&& !file_exists($basePath)) {
 mkdir
($basePath, 0777, true);
 
}


 
if (!is_writable($basePath)) {
 
throw new \Mpdf\MpdfException(sprintf('Temporary files directory "%s" is not writable', $basePath));
 
}


 $this
->basePath = $basePath;
 $this
->cleanupInterval = $cleanupInterval;
 
}


Shaharia Azam

unread,
Feb 2, 2018, 6:33:10 AM2/2/18
to google-a...@googlegroups.com
So it's working now?

--
You received this message because you are subscribed to a topic in the Google Groups "Google App Engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-appengine/pDcWUk3qLFY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-appengine+unsubscribe@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/83d57d65-4c29-46ef-8e0e-d933de0e8484%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shaharia Azam

unread,
Feb 2, 2018, 6:33:57 AM2/2/18
to Google App Engine
So it's working good now?

Dhandapani Sattanathan

unread,
Feb 2, 2018, 7:03:43 AM2/2/18
to Google App Engine
Yes Shaharia Azam, It is working fine now.

Thanks for your valuable reply. It solved the problem.
Reply all
Reply to author
Forward
0 new messages