Nextcloud PHP API (master)

IFilenameValidator

Tags
since
30.0.0

Table of Contents

Methods

isFilenameValid()  : bool
It is recommended to use `\OCP\Files\Storage\IStorage::isFileValid` instead as this only checks if the filename is valid in general but not for a specific storage which might have additional naming rules.
sanitizeFilename()  : string
Sanitize a give filename to comply with admin setup naming constrains.
validateFilename()  : void
It is recommended to use `\OCP\Files\Storage\IStorage::isFileValid` instead as this only checks if the filename is valid in general but not for a specific storage which might have additional naming rules.

Methods

isFilenameValid()

It is recommended to use `\OCP\Files\Storage\IStorage::isFileValid` instead as this only checks if the filename is valid in general but not for a specific storage which might have additional naming rules.

public isFilenameValid(string $filename) : bool
Parameters
$filename : string

The filename to check for validity

Tags
since
30.0.0
Return values
bool

sanitizeFilename()

Sanitize a give filename to comply with admin setup naming constrains.

public sanitizeFilename(string $name[, null|string $charReplacement = null ]) : string

If no sanitizing is needed the same name is returned.

Parameters
$name : string

The filename to sanitize

$charReplacement : null|string = null

Character to use for replacing forbidden ones - by default space, dash or underscore is used if allowed.

Tags
throws
InvalidArgumentException

if no character replacement was given (and the default could not be applied) or the replacement is not valid.

since
32.0.0
Return values
string

validateFilename()

It is recommended to use `\OCP\Files\Storage\IStorage::isFileValid` instead as this only checks if the filename is valid in general but not for a specific storage which might have additional naming rules.

public validateFilename(string $filename) : void

This will validate a filename and throw an exception with details on error.

Parameters
$filename : string

The filename to check for validity

Tags
throws
InvalidPathException

or one of its child classes in case of an error

since
30.0.0

        
On this page

Search results