Roman
Roman

Reputation: 3941

Laravel URL to file in storage does not work in browser

I have this filesystem config for my folder:

'apks' => [
    'driver' => 'local',
    'root' => storage_path('app/public/apks'),
    'url' => env('APP_URL') . '/storage/apks',
    'visibility' => 'public',
]

Here are app apks saved.

I need to return the URL to the file (NOT THE FILE ITSELF).

The android APK manager will then download and install the file by using the URL.

The URL is created by calling:

Storage::disk('apks')->url($result->filename)

It works, the URL looks like this:

https://www.example.com/storage/apks/app-debug.apk

BUT it can not download the file.

Also if I use this URL in the browser I get a 404 error

I would have expected that the file will be downloaded.

Upvotes: 0

Views: 1197

Answers (1)

Amit Senjaliya
Amit Senjaliya

Reputation: 2945

You need to generate a symlink for access publicly from the storage folder.

Here you can able to run below command in the composer:

php artisan storage:link

Now you can access:

https://www.example.com/storage/apks/yourfile.xyz

Upvotes: 2

Related Questions