Documentation

TemporaryFileFilterPlugin extends ServerPlugin
in package

Temporary File Filter Plugin.

The purpose of this filter is to intercept some of the garbage files operation systems and applications tend to generate when mounting a WebDAV share as a disk.

It will intercept these files and place them in a separate directory. these files are not deleted automatically, so it is advisable to delete these after they are not accessed for 24 hours.

Currently it supports:

  • OS/X style resource forks and .DS_Store
  • desktop.ini and Thumbs.db (windows)
  • .*.swp (vim temporary files)
  • .dat.* (smultron temporary files)

Additional patterns can be added, by adding on to the temporaryFilePatterns property.

Tags
copyright

Copyright (C) fruux GmbH (https://fruux.com/)

author

Evert Pot (http://evertpot.com/)

license

http://sabre.io/license/ Modified BSD License

Table of Contents

$temporaryFilePatterns  : array<string|int, mixed>
This is the list of patterns we intercept.
$server  : Server
A reference to the main Server class.
$dataDir  : string
This is the directory where this plugin will store it's files.
__construct()  : mixed
Creates the plugin.
beforeCreateFile()  : bool
This method is invoked if some subsystem creates a new file.
beforeMethod()  : bool
This method is called before any HTTP method handler.
getFeatures()  : array<string|int, mixed>
This method should return a list of server-features.
getHTTPMethods()  : array<string|int, mixed>
Use this method to tell the server this plugin defines additional HTTP methods.
getPluginInfo()  : array<string|int, mixed>
Returns a bunch of meta-data about the plugin.
getPluginName()  : string
Returns a plugin name.
getSupportedReportSet()  : array<string|int, mixed>
Returns a list of reports this plugin supports.
httpDelete()  : bool
This method handles the DELETE method.
httpGet()  : bool
This method handles the GET method for temporary files.
httpPropfind()  : bool
This method handles the PROPFIND method.
httpPut()  : bool
This method handles the PUT method.
initialize()  : mixed
Initialize the plugin.
getDataDir()  : string
This method returns the directory where the temporary files should be stored.
isTempFile()  : bool|string
This method will check if the url matches the temporary file pattern if it does, it will return an path based on $this->dataDir for the temporary file storage.

Properties

$temporaryFilePatterns

This is the list of patterns we intercept.

public array<string|int, mixed> $temporaryFilePatterns = [ '/^\._(.*)$/', // OS/X resource forks '/^.DS_Store$/', // OS/X custom folder settings '/^desktop.ini$/', // Windows custom folder settings '/^Thumbs.db$/', // Windows thumbnail cache '/^.(.*).swp$/', // ViM temporary files '/^\.dat(.*)$/', // Smultron seems to create these '/^~lock.(.*)#$/', ]

If new patterns are added, they must be valid patterns for preg_match.

Methods

__construct()

Creates the plugin.

public __construct([string|null $dataDir = null ]) : mixed

Make sure you specify a directory for your files. If you don't, we will use PHP's directory for session-storage instead, and you might not want that.

Parameters
$dataDir : string|null = null
Return values
mixed

beforeCreateFile()

This method is invoked if some subsystem creates a new file.

public beforeCreateFile(string $uri, resource $data, ICollection $parent, bool $modified) : bool

This is used to deal with HTTP LOCK requests which create a new file.

Parameters
$uri : string
$data : resource
$parent : ICollection
$modified : bool

should be set to true, if this event handler changed &$data

Return values
bool

getFeatures()

This method should return a list of server-features.

public getFeatures() : array<string|int, mixed>

This is for example 'versioning' and is added to the DAV: header in an OPTIONS response.

Return values
array<string|int, mixed>

getHTTPMethods()

Use this method to tell the server this plugin defines additional HTTP methods.

public getHTTPMethods(string $path) : array<string|int, mixed>

This method is passed a uri. It should only return HTTP methods that are available for the specified uri.

Parameters
$path : string
Return values
array<string|int, mixed>

getPluginInfo()

Returns a bunch of meta-data about the plugin.

public getPluginInfo() : array<string|int, mixed>

Providing this information is optional, and is mainly displayed by the Browser plugin.

The description key in the returned array may contain html and will not be sanitized.

Return values
array<string|int, mixed>

getPluginName()

Returns a plugin name.

public getPluginName() : string

Using this name other plugins will be able to access other plugins using \Sabre\DAV\Server::getPlugin

Return values
string

getSupportedReportSet()

Returns a list of reports this plugin supports.

public getSupportedReportSet(string $uri) : array<string|int, mixed>

This will be used in the {DAV:}supported-report-set property. Note that you still need to subscribe to the 'report' event to actually implement them

Parameters
$uri : string
Return values
array<string|int, mixed>

initialize()

Initialize the plugin.

public initialize(Server $server) : mixed

This is called automatically be the Server class after this plugin is added with Sabre\DAV\Server::addPlugin()

Parameters
$server : Server
Return values
mixed

getDataDir()

This method returns the directory where the temporary files should be stored.

protected getDataDir() : string
Return values
string

isTempFile()

This method will check if the url matches the temporary file pattern if it does, it will return an path based on $this->dataDir for the temporary file storage.

protected isTempFile(string $path) : bool|string
Parameters
$path : string
Return values
bool|string

Search results