FileUpload working perfectly locally but in production server throws 404 only when retrieving file

Hello. I have this code:
SpatieMediaLibraryFileUpload::make('notary_doc_file')
->label(__('notary_doc_file'))
->preserveFilenames()
->disk('public')
->downloadable()
->openable()
->maxSize(4096)
->acceptedFileTypes(['application/pdf'])
->columnSpanFull()
SpatieMediaLibraryFileUpload::make('notary_doc_file')
->label(__('notary_doc_file'))
->preserveFilenames()
->disk('public')
->downloadable()
->openable()
->maxSize(4096)
->acceptedFileTypes(['application/pdf'])
->columnSpanFull()
And in config\filesystems.php disks:
'public' => [
'driver' => 'local',
'root' => storage_path('app/public/upload'),
'url' => env('APP_URL').'/storage/upload',
'visibility' => 'public',
'throw' => false,
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public/upload'),
'url' => env('APP_URL').'/storage/upload',
'visibility' => 'public',
'throw' => false,
],
And locally everything works fine. It uploads the file to storage\app\public\upload\1 folder, and in production it works too. But, the problem comes when I want to "look at" the file. I have the ->openable() to let user open the PDF file. The links are: LOCALLY: http://127.0.0.1:8000/storage/upload/1/FileName.pdf and it works perfectly. IN PRODUCTION SERVER: https://apps.geslem.com/storage/upload/1/FileName.pdf and it THROWS A 404 NOT FOUND when trying to OPEN or DOWNLOAD the file. I am using Forge to deploy, the storage:link is created (in fact, the uploads works correctly). I have tried many thing with no success. Any ideas, please, of what I am doing wrong? Tks.
No description
Solution:
Solved. You were right. Symlink was "broken" or something strange. I deleted the storage folder and generate symlink again and solved....
Jump to solution
3 Replies
DrByte
DrByte15mo ago
Your symlink is probably wrong on the server. Have you tried using disk('public')->directory('upload') with the default public disk configuration (ie: without adding /upload in the filesystems.php config)
Albert Lens
Albert LensOP15mo ago
Same result. I have changed what you mention, have tested locally and OK but again problems in the server. Upload is Ok, but open or download 404 NOT FOUND
Solution
Albert Lens
Albert Lens15mo ago
Solved. You were right. Symlink was "broken" or something strange. I deleted the storage folder and generate symlink again and solved.
Want results from more Discord servers?
Add your server