Retrieving File Size


I created an app that writes all files activity on a log “only files activities” , such as creating, deleting renaming, the response contains the use, the action, “rename for example” and the path.

I only need to get the file size, how to do that? its from this function if yes how to use the function? since I don’t know what that function returns

or there is a different way?

using the IRootFolder:

$node = $rootFolder->getUserFolder(userId)->get($path);

how does $node return time? if it doesn’t is there another way?

getMTime() will returns the last modification time

how to create instance of the rootFolder ? how to get $rootFolder?

thanks for the getMTime()

Have a look here, and to the __construct() method of the same class, to see how to call IRootFolder using automatic DI

You will need to share your source for a more detailed support

unfortunately I don’t have the app on the GitHub but assume I want to get file size here

namespace OCA\Tracer\Actions;
use OCP\Files\IRootFolder;
use OCP\Files\Node;

class Files extends Action {
	public function create(array $params) {
		if ($params['path'] === '/' || $params['path'] === '' || $params['path'] === null) {
		$str = 'test';
		$node = $this->rootFolder->getUserFolder($str)->get($params['path']);
			'File created: "%s"',

at the script in the link FilesService.php the object rootFolder was passed to class FilesService by the constructor not created.
note that I’m using same logger of the NextCloud server
I appreciate the help

refer to this link