Sails.Js - How I can watch file/directory

2019-08-09 20:07发布

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?

标签: sails.js
1条回答
时光不老,我们不散
2楼-- · 2019-08-09 20:36

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…

查看更多
登录 后发表回答