final class UploadStaging (View source)

internal  UploadService uses this boundary before any MIME, image, or final-storage operation.
 

Creates sealed upload snapshots in private writable storage while enforcing byte limits during streaming.

Constants

private COPY_BYTES

private CREATE_ATTEMPTS

Methods

__construct(TranslatorInterface $translator, Filesystem $filesystem, UploadPathPolicy $pathPolicy, ChunkUploadConfig|null $cleanupConfig = null)

Retains the private path, filesystem, and translated failure boundaries used by every upload snapshot.

stage(UploadedFileInterface|null $file, int $maxBytes)

Copies an uploaded stream exactly once and returns its measured immutable snapshot.

stageBytes(string $contents, string $clientFilename, int $maxBytes)

Seals framework-generated bytes as a second private snapshot before final publication.

void

Verifies that a sealed snapshot still has its measured size and digest.

void
void
discard(StagedUpload|null $upload)

Removes a snapshot without allowing cleanup failures to hide the primary upload outcome.

void
int
cleanupOrphans(int|null $now = null)

Reclaims a bounded number of old snapshots whose process lease is no longer active.

int

Details

__construct

__construct(TranslatorInterface $translator, Filesystem $filesystem, UploadPathPolicy $pathPolicy, ChunkUploadConfig|null $cleanupConfig = null)

Retains the private path, filesystem, and translated failure boundaries used by every upload snapshot.

Parameters

TranslatorInterface $translator
Filesystem $filesystem
UploadPathPolicy $pathPolicy
ChunkUploadConfig|null $cleanupConfig

stage

StagedUpload stage(UploadedFileInterface|null $file, int $maxBytes)

Copies an uploaded stream exactly once and returns its measured immutable snapshot.

The client-reported size is deliberately ignored; the byte limit is enforced before each staged write.

Parameters

UploadedFileInterface|null $file
int $maxBytes

Return Value

StagedUpload

Exceptions

UploadValidationException
UploadStorageException

stageBytes

StagedUpload stageBytes(string $contents, string $clientFilename, int $maxBytes)

Seals framework-generated bytes as a second private snapshot before final publication.

Parameters

string $contents
string $clientFilename
int $maxBytes

Return Value

StagedUpload

Exceptions

UploadValidationException
UploadStorageException

assertIntact

void assertIntact(StagedUpload $upload)

Verifies that a sealed snapshot still has its measured size and digest.

Parameters

StagedUpload $upload

Return Value

void

Exceptions

UploadStorageException

discard

void discard(StagedUpload|null $upload)

Removes a snapshot without allowing cleanup failures to hide the primary upload outcome.

Parameters

StagedUpload|null $upload

Return Value

void

cleanupOrphans

int cleanupOrphans(int|null $now = null)

Reclaims a bounded number of old snapshots whose process lease is no longer active.

Files outside the private staging root, symbolic links, recent snapshots, and locked snapshots are ignored.

Parameters

int|null $now

Return Value

int