WordPress\AiClient\Files\DTO
File::convertFileToBase64
Converts a local file to base64.
Метод класса: File{}
Хуков нет.
Возвращает
Строку. The base64-encoded file data.
Использование
// private - только в коде основоного (родительского) класса $result = $this->convertFileToBase64( $filePath ): string;
- $filePath(строка) (обязательный)
- The path to the local file.
Список изменений
| С версии 0.1.0 | Введена. |
Код File::convertFileToBase64() File::convertFileToBase64 WP 7.0
private function convertFileToBase64(string $filePath): string
{
$fileContent = @file_get_contents($filePath);
if ($fileContent === \false) {
throw new RuntimeException(sprintf('Unable to read file: %s', $filePath));
}
return base64_encode($fileContent);
}