ivanvermeyen / laravel-google-drive-demo

Laravel & Google Drive Storage - Demo project with Laravel 5.4
403 stars 155 forks source link

Laravel 7 donwload files in Google Chrome/Safari/Fire Fox mobile error #91

Open felipe-machado09 opened 3 years ago

felipe-machado09 commented 3 years ago

Hello,

When I try to download to my phone using the google chrome browser

the error returns to the server problem but when i do it using the computer the same process i have no problems

I tested on Safari Firefox Google Chrome and in these above I got the error

but when I tested it on the Samsung S10 + phone's native browser it downloads successfully

I don't know what to do anymore because this error doesn't make sense

i upload one video in wetransfer but the link expires in one week if wanna link again ask me

https://we.tl/t-TVs7coZME8

note: i'm doing this way to go less to the google api because as i already have the data in the front listing i just send it to the controller also

WhatsApp Image 2020-11-29 at 22 59 19

`public function downloadFile(Request $request) {

    $user = Auth::user();
    $name = $request->input('name');
    $type = $request->input('type');
    $path = $request->input('path');
    $filename = $request->input('filename');
    $extension = $request->input('extension');
    $timestamp = $request->input('timestamp');
    $mimetype = $request->input('mimetype');
    $size = $request->input('size');
    $dirname = $request->input('dirname');
    $basename = $request->input('basename');

    $historico = new DonwloadHistory();

    $historico->user_id = $user->id;
    $historico->name = $name;
    $historico->type = $type ;
    $historico->path = $path;
    $historico->filename = $filename;
    $historico->extension = $extension;
    $historico->timestamp = $timestamp;
    $historico->mimetype = $mimetype;
    $historico->size = $size;
    $historico->dirname = $dirname;
    $historico->basename = $basename;
    $historico->save();

    $rawData = Storage::cloud()->get($path);

    return response($rawData, 200)
        ->header('ContentType', $mimetype)
        ->header('Content-Disposition', "attachment; filename=$name");

    // return response($rawData, 200)
    //     ->header('ContentType', $file['mimetype'])
    //     ->header('Content-Disposition', "attachment; filename=$fileName");
}`
ivanvermeyen commented 3 years ago

Hi, can you see in the Laravel log what the exception is?

felipe-machado09 commented 3 years ago

hello thanks for the quick answer did you get to watch the video?

I looked at the log and there was no error about the download

why wouldn't it be possible to use response () -> download () ?

ivanvermeyen commented 3 years ago

Logically, if it works on other browsers/devices then the server <> Google part is working. So it must the Chrome browser on the phone.

Can this be related to this issue, thus just a Chrome bug? https://github.com/nextcloud/server/issues/421

Their solution: https://github.com/nextcloud/server/pull/1454

Not sure how to apply this to Laravel though.