Distinguish Between File and Folder

Hi,

I have an app which uses web hooks to get information about files activities in the Util the code for the hook is like this

<?php
use	OCP\Util;
protected function fileHooks(ILogger $logger) {
		
		$rootFolder = $this->getContainer()->getServer()->getRootFolder();
		
		$fileActions = new Files($rootFolder, $logger);
		$eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
		
		Util::connectHook(
			Filesystem::CLASSNAME,
			Filesystem::signal_post_rename,
			$fileActions,
			'rename'
		);
		Util::connectHook(
			Filesystem::CLASSNAME,
			Filesystem::signal_post_create,
			$fileActions,
			'create'
		);

, I’m using the functions in the class Node.php and all works fine.

the only thing is that, i have the path of the file or the folder that has been created, i need to know the item that was created whether its a file or a folder, i saw this code and i did the same as the following

<?php
$internalPath = $node->getInternalPath();
$test4 = \OC\Files\Filesystem::is_file($internalPath);
if($test4){
		$this->logbasic(sprintf("FILE WORKED"));    		
		} else {
		$this->logbasic(sprintf("FILE DIDNT WOKR"));
		}

yet the results is always false, when i log the $test4 using the same ILogger the results is null, keep in mind that the internalPath looks like files\/test.txt also i use S3 bucket as a primary storage

i noticed in the logs when i create a folder i get:
{"reqId":"wPDy0s8TkhSJvRqlZHuR","level":1,"time":"2018-02-19T07:43:55+00:00","remoteAddr":"10.0.10.215","user":"userS","app":"admin_audit","method":"MKCOL","url":"\/nextcloud\/remote.php\/dav\/files\/userS\/abc","message":"File created: \"\/abc\"","userAgent":"Mozilla\/5.0 (Windows) mirall\/2.3.3 (build 1) (Nextcloud)","version":"14.0.0.0"}
the method is "MKCOL" but when i create a file the method in the logs is "PUT", can i rely on that to distinguish a file from a folder?

created item is a file or a folder, i didn’t find anything in that file that tells me how to distinguish between a file and folder.

is there any way to know what was created is a file or a folder?

Hi,

I moved your question to the app dev category. Unfortunately I can’t help with your question however.

it was a path problem, since the internal path is returned in this for \/files\/userS\/abc it wont be recognized so i deleted the files and the userS typed the path as /abc and it worked