Sails.Js - How I can watch file/directory

依然范特西╮ 提交于 2019-12-13 00:53:35

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!