问题
My question is about i store files (audio) in a directory with a reference in db ( mysql) and i wanna set a lifetime to this file to prevent server overflow.
I search in google and sails doc but not see anything reference, Anyone know how to i can watch the file to remove after do the time?
回答1:
The best way its make a php file to call an localhost url [you can make a route locally by policies] and call that file with crontab every x/time
just do:
task.php
<?php
$url = 'http://localhost:1337/task';
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_HEADER, false );
curl_exec( $ch);
?>
This happens because sails its a REST api and only works with petition and you cant automate task like php,java,etc…
来源:https://stackoverflow.com/questions/34435205/sails-js-how-i-can-watch-file-directory