cfiles
cfiles copied to clipboard
From file guid, how can I know if a file is a "cfile" file ?
Context: I have a custom module with some actions when a file is downloaded. I need to know if the downloaded file is managed by cfile.
The way I do:
Get file guid
from request parameters:
$fileguid = Yii::$app->request->get('guid')
Then query in db 'file'
table to get the file id
Then query in db cflies_file
table and check if the id
is in the table.
If the id is in the table it means that it's a "cfile" file.
Issue: Some times it works, some times it doesn't. This is because a lot of files that are referenced in folders are not in the "cfiles_file" table. It seems that only "old" files are in the table but not new files. When I browse in the folders, all files are present and download counter is updated. But I cannot find counter value of new files in db So I worry about the way it works.
Questions
- Please, how does it work?
- From de file
guid
, is there a simple way to check is the file is a "cfile" file?
Thank you in advance for your comments
In the meantime I found that I was on the wrong way (newbee error). I need to use object_id
. from file
table and compare with id
in cfile-file
table