My default download method is public, but I need save some file on private folder, I am doing this:
//...
$file = file_save_data($handle, 'private://example.zip', FILE_EXISTS_REPLACE);
//...
Now when I try show to download it:
//...
$file = file_load($file_fid);
$url = file_create_url($file->uri);
$output['download'] = [
'#type' => 'markup',
'#markup' => l(t('Download'), $url),
];
return $output;
//...
If I do click on the url, I get:
Access denied. You are not authorized to access this page.
I am superadmin (uid = 1). How I can management those files for me and for others users?