PHP从S3下载MP4始终会导致文件的文件类型不受支持

问题描述

我正在使用下面的代码从S3和服务器上下载Laravel项目中的mp4文件,这些文件可以很好地下载,但在播放时总是会出错,因为文件类型不受支持。

方法1:

$s3 = \CommonHelper::getS3ClientObj();
$file = $s3->getObjectUrl('video-testimonials',"96066883.mp4",'+5 minutes',['ResponseContentDisposition' => 'attachment; filename="96066883.mp4"']);
$filename = '96066883.mp4';
header('Content-Description: File Transfer');
header("Content-type:  video/$type"); # Without this and line below didn't worked
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate');
header('Pragma: public');
ob_clean();
flush();
readfile($file);
exit;

方法2:

$file= "/var/www/html/videos/$vid.$type";
$headers = array(
    "Content-Type: video/$type",);
return Response::download($file,"video-$vid.$type",$headers);

这两种方法都可以下载文件,但是它永远无法播放。文件名和路径正确。我现在还能尝试什么解决方法?

在媒体播放器中播放视频时出错:https://www.screencast.com/t/MnXVIrZh

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...