public function fetchFile(Request
$request, ?string
$tempFile = null
): MediaFile
{ if ($tempFile === null
) { $tempFile =
tempnam(sys_get_temp_dir(), ''
);
} $contentType =
$request->headers->
get('content_type', ''
);
if (str_starts_with($contentType, 'application/json'
)) { return $this->fileFetcher->
fetchFileFromURL($request,
$tempFile ?: ''
);
} return $this->fileFetcher->
fetchRequestData($request,
$tempFile ?: ''
);
} /**
* @return array{content: string, fileName: non-falsy-string, mimeType: string|null}
*/
public function getAttachment(MediaEntity
$media, Context
$context): array
{ $fileBlob = '';