protected function RemotePostWebformHandler::getResponseFileData in Webform 8.5
Get request file data.
Parameters
int $fid: A file id.
string|null $prefix: A prefix to prepended to data.
Return value
array An associative array containing file data (name, uri, mime, and data).
1 call to RemotePostWebformHandler::getResponseFileData()
- RemotePostWebformHandler::getRequestData in src/
Plugin/ WebformHandler/ RemotePostWebformHandler.php - Get a webform submission's request data.
File
- src/
Plugin/ WebformHandler/ RemotePostWebformHandler.php, line 801
Class
- RemotePostWebformHandler
- Webform submission remote post handler.
Namespace
Drupal\webform\Plugin\WebformHandlerCode
protected function getResponseFileData($fid, $prefix = '') {
/** @var \Drupal\file\FileInterface $file */
$file = File::load($fid);
if (!$file) {
return [];
}
$data = [];
$data[$prefix . 'id'] = (int) $file
->id();
$data[$prefix . 'name'] = $file
->getFilename();
$data[$prefix . 'uri'] = $file
->getFileUri();
$data[$prefix . 'mime'] = $file
->getMimeType();
$data[$prefix . 'uuid'] = $file
->uuid();
if ($this->configuration['file_data']) {
$data[$prefix . 'data'] = base64_encode(file_get_contents($file
->getFileUri()));
}
return $data;
}