关于vivo系统自带浏览器无法通过laravel下载文件

是这样的,我在服务器上有.mp3文件,然后通过laravel的response()->download()方法下载,但是在vivo系统自带浏览器上下载时,文件实际大小5MB,但是下载下来只有1~2KB,也就导致了文件无法使用。目前好像只是发现在vivo系统自带浏览器上有这个问题,在其他浏览器其他牌子手机上都是正常的。这个问题会是什么原因造成的呢?有大佬知道吗。

下面是我的代码

Route::get('download/{file}', function ($file) {
    return Storage::disk(config('admin.upload.disk'))
        ->download(urlencode($file));
});
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 1
Summer

试试看修改标头,以下代码没测过

$file = new File(storage_path()."/songs/".$song->name.".mp3");

$headers = array();
$headers['Content-Type'] = 'audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3';
$headers['Content-Length'] = $file->getSize();
$headers['Content-Transfer-Encoding'] = 'binary';
$headers['Accept-Range'] = 'bytes';
$headers['Cache-Control'] = 'must-revalidate, post-check=0, pre-check=0';
$headers['Connection'] = 'Keep-Alive';
$headers['Content-Disposition'] = 'attachment; filename="'.$song->name.'.mp3"';

return Response::download($file, $song->name, $headers);
3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!