FileUpload (Download Private)

When i upload a file it stores it perfectly in the storage/private/gravityforms folder but when trying to download it back it won't be able to access it. (404)
3 Replies
BlackShadow
BlackShadowOP17mo ago
Forms\Components\FileUpload::make('form_file')
->enableDownload()
->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file): string {
return (string)str($file->getClientOriginalName())->prepend(now()->format('d-m-y-h-i-s') . '-form-file-');
})
->label(__('Form'))
->disk('private')
->directory('gravityforms')
->required(),
Forms\Components\FileUpload::make('form_file')
->enableDownload()
->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file): string {
return (string)str($file->getClientOriginalName())->prepend(now()->format('d-m-y-h-i-s') . '-form-file-');
})
->label(__('Form'))
->disk('private')
->directory('gravityforms')
->required(),
JibayMcs
JibayMcs17mo ago
The private folder is not linked, while you do a php artisan storage:link So I think the file upload is searching in your public/storage who's linked to storage/app/public and not private for public url, so why the 404 Can you share your configuration of your 'private' disk in your config/filesystem.php ? For me the best way is to store it in the public folder, but with a custom middleware if you want to disable the access with a direct url, but not for the FileUpload component. Because the private dir is... private and not supposed to be public or access dowloading
BlackShadow
BlackShadowOP17mo ago
'private' => [
'driver' => 'local',
'root' => storage_path('app/private'),
'visibility' => 'public',
'throw' => true,
],
'private' => [
'driver' => 'local',
'root' => storage_path('app/private'),
'visibility' => 'public',
'throw' => true,
],
It contains some data i don't want to have publicily available. But users can upload it from the forms and download it.
Want results from more Discord servers?
Add your server