CoolCMS API

DropzoneTempRoot
in package

FinalYes

The single place that builds the root of the dropzone temporary folders (`<appTempDir>/dropzone`).

Four parties use the root and must agree on it exactly:

  • both UploaderDropzone components (Front and Admin) store uploaded files in it (<root>/<subDir>/Y/m/d/<token>/),
  • the cron DropzoneTempPresenter cleans it,
  • the Api read of an item {name, path} (UploadedItem) accepts only a file that lies inside the root after realpath().

IMPORTANT: without that containment check, path would allow reading any file on the server.

Table of Contents

Constants

DIR_NAME  : string = 'dropzone'
Name of the subfolder in `appTempDir`.

Methods

buildFileName()  : string
Builds the dropzone temporary file name: `<time>_<random>_<original name>.<extension>`. The original name (already `getSanitizedName()`, here further reduced to `[A-Za-z0-9-]`, at most 60 characters) is kept so that the Api can report rejected items under a name the user knows ({@see UploadRejection::displayName()} strips the prefix). Without a usable name the shape is `<time>_<random>.<extension>`. The caller passes an already verified extension.
fromAppTempDir()  : string|null
Returns the root without a trailing slash, or `null` when `appTempDir` is not set (an empty string must not turn the root into `/dropzone`).
fromSetting()  : string|null
Same from the `appTempDir` setting value (`['rel' => ..., 'abs' => ...]`), the shape returned by `SettingContext::get(0, 'appTempDir')` and `Config::value(0, 'appTempDir')`.

Constants

DIR_NAME

Name of the subfolder in `appTempDir`.

public string DIR_NAME = 'dropzone'

Methods

buildFileName()

Builds the dropzone temporary file name: `<time>_<random>_<original name>.<extension>`. The original name (already `getSanitizedName()`, here further reduced to `[A-Za-z0-9-]`, at most 60 characters) is kept so that the Api can report rejected items under a name the user knows ({@see UploadRejection::displayName()} strips the prefix). Without a usable name the shape is `<time>_<random>.<extension>`. The caller passes an already verified extension.

public static buildFileName(string $sanitizedName, string $extension, int $time, string $random) : string
Parameters
$sanitizedName : string
$extension : string
$time : int
$random : string
Return values
string

fromAppTempDir()

Returns the root without a trailing slash, or `null` when `appTempDir` is not set (an empty string must not turn the root into `/dropzone`).

public static fromAppTempDir(mixed $appTempDirAbs) : string|null
Parameters
$appTempDirAbs : mixed
Return values
string|null

fromSetting()

Same from the `appTempDir` setting value (`['rel' => ..., 'abs' => ...]`), the shape returned by `SettingContext::get(0, 'appTempDir')` and `Config::value(0, 'appTempDir')`.

public static fromSetting(mixed $appTempDir) : string|null
Parameters
$appTempDir : mixed
Return values
string|null
On this page

Search results