cfiles icon indicating copy to clipboard operation
cfiles copied to clipboard

From file guid, how can I know if a file is a "cfile" file ?

Open Gilbertdelyon opened this issue 11 months ago • 1 comments

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

Gilbertdelyon avatar Feb 29 '24 20:02 Gilbertdelyon

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

Gilbertdelyon avatar Feb 29 '24 20:02 Gilbertdelyon