Sails.Js - 我如何观看文件/目录 [英] Sails.Js - How I can watch file/directory
问题描述
我的问题是关于我将文件(音频)存储在一个目录中,并在 db(mysql)中有一个引用,我想为此文件设置一个生命周期以防止服务器溢出.
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.
我在谷歌和sails doc中搜索但没有看到任何参考资料,有人知道如何在完成时间后删除文件吗?
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?
推荐答案
最好的方法是制作一个 php 文件来调用 localhost url [你可以通过策略在本地创建一个路由] 并每隔 x/时间使用 crontab 调用该文件
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
就去做:
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);
?>
发生这种情况是因为它使用的是 REST api 并且仅适用于请求,而您不能自动执行诸如 php、java 等任务...
This happens because sails its a REST api and only works with petition and you cant automate task like php,java,etc…
这篇关于Sails.Js - 我如何观看文件/目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!