I have create custom REST API in my project. Also configure private file system also, one any file(image / PDF) is uploaded to any content it is saved in private file system.
In My API I am fetch paragraph data by Paragraph ID. including file(image / PDF).
For File I am creating file URL by file_create_url() function to get file path.
$paragraphObj[$fieldDefination->label()]['fileName'] = file_create_url($val->entity->getFileUri());
But if I am include above line it show below error message
"message":"A fatal error occurred: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\\rest\\ResourceResponse."
I am debug the code and found it should be because of file_create_url(), same code is working fine if file is saved in public folder. If file is in private it show error.
Please let me know what is the issue if you know.
Comments