private readonly FileSaver
$fileSaver,
private readonly StorefrontMediaValidatorRegistry
$validator ) { } /**
* @throws FileTypeNotAllowedException
* @throws MediaException
*/
public function upload(UploadedFile
$file, string
$folder, string
$type, Context
$context, bool
$isPrivate = false
): string
{ $this->
checkValidFile($file);
$this->validator->
validate($file,
$type);
$mediaFile =
new MediaFile( $file->
getPathname(),
$file->
getMimeType() ?? '',
$file->
getClientOriginalExtension(),
$file->
getSize() ?: 0
);
$mediaId =
$this->mediaService->
createMediaInFolder($folder,
$context,
$isPrivate);