spatie / flysystem-dropbox

A flysystem driver for Dropbox that uses the v2 API
https://freek.dev/734-dropbox-will-turn-off-v1-of-their-api-soon-its-time-to-update-your-php-application
MIT License
343 stars 50 forks source link

Can't download files from Dropbox since upgrading to Laravel 10, but all other functions work fine #98

Open krismanning opened 1 week ago

krismanning commented 1 week ago

Hi folks,

Hope you can help me with this. I'm currenly upgrading a Laravel application from version 9 to version 11.

The app has functionality that allows to upload files to Dropbox, create folders, delete files and folders and of course to download files as well.

I took the upgrade in stages but the moment I went to Laravel 10 I could no longer download the files from dropbox, but all the other functions (create folders, jupload, delete files and folders) still work fine.

The browser throws this error:Image

The code looks like this....

        if (Storage::disk('dropbox')->exists($filename)) {

            Log::channel('daily')->info('File downloaded', [
                'file' => $filename,
                'user' => Auth::user()->name,
            ]);

            return Storage::disk('dropbox')->download($filename);
        }

The 'exists' check works fine. But the download doesn't and the browser throws an error. It worked fine in Laravel 9 but fails the moment I upgrade to version 10.

Storage::url works fine as well and returns a working URL for the file. Its just the download that doesnt Do I need to apply a header in the download call maybe?

Any ideas what it could be?

Thanks,

Kris

krismanning commented 1 week ago

Just to add, I have temporarily solved my problem by doing this (I know it could be a single line), it works fine but I'd prefer the download function.

 $url = Storage::disk('dropbox')->url($filename);
 return redirect($url);