final class UploadFactory (View source)

Exposes request-scoped uploaders whose named profiles are resolved against the current application context.

Profile failures are translated into upload validation errors before storage is attempted.

Methods

__construct(UploadConfig $config, UploadService $service, ServerRequestInterface $request, TranslatorInterface $translator, ApplicationContext $context, UploadPathPolicy|null $pathPolicy = null)

Binds resolved profile configuration to the request and its public or private storage boundary.

file(string $profile = 'default')

Creates a generic uploader for a configured profile without reading request input yet.

image(string $profile = 'default')

Creates an image uploader for a configured profile without reading request input yet.

upload(string $inputName, string $profile = 'default')

Resolves one request upload by input name and stores it through the selected generic profile.

uploadImage(string $inputName, string $profile = 'default')

Resolves one request upload by input name and stores it through the selected image profile.

Wraps an already-resolved generic policy in an uploader without consulting named configuration.

Wraps an already-resolved image policy in an uploader without consulting named configuration.

uploadWithOptions(string $inputName, FileUploadOptions $options)

Resolves and stores one request upload using a caller-supplied generic policy.

uploadImageWithOptions(string $inputName, ImageUploadOptions $options)

Resolves and stores one request upload using a caller-supplied image policy.

fileOptions(string $profile = 'default')

Resolves a named generic profile into visibility-constrained absolute and storage-relative paths.

imageOptions(string $profile = 'default')

Resolves a named image profile into visibility-constrained absolute and storage-relative paths.

Details

__construct

__construct(UploadConfig $config, UploadService $service, ServerRequestInterface $request, TranslatorInterface $translator, ApplicationContext $context, UploadPathPolicy|null $pathPolicy = null)

Binds resolved profile configuration to the request and its public or private storage boundary.

Parameters

UploadConfig $config
UploadService $service
ServerRequestInterface $request
TranslatorInterface $translator
ApplicationContext $context
UploadPathPolicy|null $pathPolicy

file

ConfiguredFileUploader file(string $profile = 'default')

Creates a generic uploader for a configured profile without reading request input yet.

Parameters

string $profile

Return Value

ConfiguredFileUploader

Exceptions

UploadValidationException

image

ConfiguredImageUploader image(string $profile = 'default')

Creates an image uploader for a configured profile without reading request input yet.

Parameters

string $profile

Return Value

ConfiguredImageUploader

Exceptions

UploadValidationException

upload

UploadedFile upload(string $inputName, string $profile = 'default')

Resolves one request upload by input name and stores it through the selected generic profile.

Parameters

string $inputName
string $profile

Return Value

UploadedFile

Exceptions

UploadValidationException

uploadImage

UploadedImage uploadImage(string $inputName, string $profile = 'default')

Resolves one request upload by input name and stores it through the selected image profile.

Parameters

string $inputName
string $profile

Return Value

UploadedImage

Exceptions

UploadValidationException

fileWithOptions

Wraps an already-resolved generic policy in an uploader without consulting named configuration.

Parameters

FileUploadOptions $options

Return Value

ConfiguredFileUploader

imageWithOptions

Wraps an already-resolved image policy in an uploader without consulting named configuration.

Parameters

ImageUploadOptions $options

Return Value

ConfiguredImageUploader

uploadWithOptions

UploadedFile uploadWithOptions(string $inputName, FileUploadOptions $options)

Resolves and stores one request upload using a caller-supplied generic policy.

Parameters

string $inputName
FileUploadOptions $options

Return Value

UploadedFile

Exceptions

UploadValidationException

uploadImageWithOptions

UploadedImage uploadImageWithOptions(string $inputName, ImageUploadOptions $options)

Resolves and stores one request upload using a caller-supplied image policy.

Parameters

string $inputName
ImageUploadOptions $options

Return Value

UploadedImage

Exceptions

UploadValidationException

fileOptions

FileUploadOptions fileOptions(string $profile = 'default')

Resolves a named generic profile into visibility-constrained absolute and storage-relative paths.

Parameters

string $profile

Return Value

FileUploadOptions

Exceptions

UploadValidationException

imageOptions

ImageUploadOptions imageOptions(string $profile = 'default')

Resolves a named image profile into visibility-constrained absolute and storage-relative paths.

Parameters

string $profile

Return Value

ImageUploadOptions

Exceptions

UploadValidationException