final class UploadPathPolicy (View source)

internal  UploadFactory and upload storage apply this boundary for configured and custom options.
 

Resolves visibility-specific upload roots and rejects paths that escape them or traverse symbolic links.

Constants

private PRIVATE_ROOT

private STAGING_ROOT

private CHUNK_ROOT

Methods

Retains the application paths used to separate public publication from private writable storage.

static string
normalizeRelativeDirectory(string $directory)

Normalizes a configured directory and rejects absolute, traversing, control-character, or platform-ambiguous paths.

string
string
root(UploadVisibility $visibility)

Returns the absolute storage root assigned to the requested visibility.

string
string

Returns the private writable root used for immutable upload snapshots before validation and publication.

string
string

Returns the private writable root used for incomplete chunk sessions.

string
string
targetDirectory(UploadVisibility $visibility, string $relativeDirectory)

Resolves a safe configured directory below its visibility-specific storage root.

string
string
storedRelativeDirectory(UploadVisibility $visibility, string $relativeDirectory)

Returns the persisted path relative to the public root or writable storage root.

string
void

Rejects deployments where private upload storage is reachable below the configured public web root.

void
void

Rejects deployments where upload snapshots could be reached through the public web root.

void
void

Rejects deployments where incomplete chunk payloads could be reached through the public web root.

void
void
assertTargetDirectory(string $targetDirectory, UploadVisibility $visibility)

Rejects runtime targets outside their assigned root or behind any symbolic-link path component.

void
void
assertStagingDirectory(string $directory)

Rejects staging directories outside the private staging root or behind symbolic-link components.

void
void
assertChunkDirectory(string $directory)

Rejects chunk storage paths outside the private root or behind symbolic-link components.

void

Details

__construct

__construct(ApplicationContext $context)

Retains the application paths used to separate public publication from private writable storage.

Parameters

ApplicationContext $context

normalizeRelativeDirectory

static string normalizeRelativeDirectory(string $directory)

Normalizes a configured directory and rejects absolute, traversing, control-character, or platform-ambiguous paths.

Parameters

string $directory

Return Value

string

Exceptions

InvalidArgumentException

root

string root(UploadVisibility $visibility)

Returns the absolute storage root assigned to the requested visibility.

Parameters

UploadVisibility $visibility

Return Value

string

stagingRoot

string stagingRoot()

Returns the private writable root used for immutable upload snapshots before validation and publication.

Return Value

string

chunkRoot

string chunkRoot()

Returns the private writable root used for incomplete chunk sessions.

Return Value

string

targetDirectory

string targetDirectory(UploadVisibility $visibility, string $relativeDirectory)

Resolves a safe configured directory below its visibility-specific storage root.

Parameters

UploadVisibility $visibility
string $relativeDirectory

Return Value

string

storedRelativeDirectory

string storedRelativeDirectory(UploadVisibility $visibility, string $relativeDirectory)

Returns the persisted path relative to the public root or writable storage root.

Parameters

UploadVisibility $visibility
string $relativeDirectory

Return Value

string

assertStorageRootsSeparated

void assertStorageRootsSeparated()

Rejects deployments where private upload storage is reachable below the configured public web root.

Return Value

void

Exceptions

LogicException

assertStagingRootSeparated

void assertStagingRootSeparated()

Rejects deployments where upload snapshots could be reached through the public web root.

Return Value

void

Exceptions

LogicException

assertChunkRootSeparated

void assertChunkRootSeparated()

Rejects deployments where incomplete chunk payloads could be reached through the public web root.

Return Value

void

Exceptions

LogicException

assertTargetDirectory

void assertTargetDirectory(string $targetDirectory, UploadVisibility $visibility)

Rejects runtime targets outside their assigned root or behind any symbolic-link path component.

Parameters

string $targetDirectory
UploadVisibility $visibility

Return Value

void

Exceptions

InvalidArgumentException

assertStagingDirectory

void assertStagingDirectory(string $directory)

Rejects staging directories outside the private staging root or behind symbolic-link components.

Parameters

string $directory

Return Value

void

Exceptions

InvalidArgumentException

assertChunkDirectory

void assertChunkDirectory(string $directory)

Rejects chunk storage paths outside the private root or behind symbolic-link components.

Parameters

string $directory

Return Value

void

Exceptions

InvalidArgumentException