简体   繁体   中英

Laravel - Can't download file from storage at Ubuntu server with Nginx

So I'm testing that a Laravel app that I just deployed to an Ubuntu server with Nginx works correctly, and I reached a point where I need to download some files that were upload from the front end using Angular.

I can upload files with no problem and I made sure that those are actually in the server and yeah, they are saved as expected.

However when I need to download them I get the error: "Failed to create the file"

It worked on my local machine, so I'm guessing is kind of a configuration problem but I'm not sure what to change yet.

The file is being requested through a GET request with Http with the header: { responseType: ResponseContentType.Blob }, the latter being part of Angular.

And in Laravel this is how I'm returning the file:

public function download($activityId) {
    $activity = $activity = Activity::find($activityId, ['student_id', 'file_storage']);

    $file = public_path() . '/storage/activityFiles/' . $activity['student_id'] . '/' . $activity['file_storage'];

    return response()->download($file);
}

What can I be missing?

I decided to take a look at the laravel logs to see a little further the problem.

The problem was that I forgot to create the symbolic link to the storage.

That fixed the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM