final class ChunkUploadService (View source)

Coordinates sequential chunk transport before delegating completed files to the existing upload pipeline.

The service is request-scoped because it resolves the configured file or image uploader through UploadFactory.

Constants

private MAX_FILENAME_BYTES

private MAX_PROFILE_BYTES

Methods

Combines transport limits, temporary persistence, and the established profile-based upload boundary.

int

Returns the server-authoritative maximum payload size for one append request.

int
start(string $kind, string $profile, string $originalFilename, int $declaredSize, array $context = [])

Creates a temporary session for an explicit file or image profile after resolving its maximum final size.

session(string $uploadId)

Returns server-authoritative metadata for an active session without exposing its payload.

append(string $uploadId, int $offset, StreamInterface $body)

Appends one non-empty permitted chunk at the exact next byte offset of an active session.

complete(string $uploadId)

Verifies that the assembled payload is complete and submits it to the standard configured upload pipeline.

void
abort(string $uploadId)

Idempotently removes a temporary session and all of its assembled data under its session lock.

void
array

Removes expired sessions, old unreadable metadata, and bounded inactive retirement leftovers.

array

Details

__construct

__construct(ChunkUploadConfig $config, FilesystemChunkUploadSessionStore $store, UploadFactory $uploads, UploadStorage $storage, UploadService $uploadService)

Combines transport limits, temporary persistence, and the established profile-based upload boundary.

Parameters

ChunkUploadConfig $config
FilesystemChunkUploadSessionStore $store
UploadFactory $uploads
UploadStorage $storage
UploadService $uploadService

chunkBytes

int chunkBytes()

Returns the server-authoritative maximum payload size for one append request.

Return Value

int

start

ChunkUploadSession start(string $kind, string $profile, string $originalFilename, int $declaredSize, array $context = [])

Creates a temporary session for an explicit file or image profile after resolving its maximum final size.

The declared size is reserved as an upper bound before any chunk data is written.

Parameters

string $kind
string $profile
string $originalFilename
int $declaredSize
array $context

Return Value

ChunkUploadSession

session

ChunkUploadSessionDescriptor session(string $uploadId)

Returns server-authoritative metadata for an active session without exposing its payload.

Parameters

string $uploadId

Return Value

ChunkUploadSessionDescriptor

append

ChunkUploadSession append(string $uploadId, int $offset, StreamInterface $body)

Appends one non-empty permitted chunk at the exact next byte offset of an active session.

The body is read under the session lock and cannot advance metadata unless the complete chunk is persisted.

Parameters

string $uploadId
int $offset
StreamInterface $body

Return Value

ChunkUploadSession

complete

UploadedFile|UploadedImage complete(string $uploadId)

Verifies that the assembled payload is complete and submits it to the standard configured upload pipeline.

Validation failures discard the temporary session, while unexpected storage or infrastructure failures leave it intact.

Parameters

string $uploadId

Return Value

UploadedFile|UploadedImage

abort

void abort(string $uploadId)

Idempotently removes a temporary session and all of its assembled data under its session lock.

Parameters

string $uploadId

Return Value

void

cleanupExpired

array cleanupExpired()

Removes expired sessions, old unreadable metadata, and bounded inactive retirement leftovers.

Return Value

array