php - 从 AWS Glacier 下载文件时如何找到文件的扩展名?
问题描述
我在 AWS Glacier 中存档了很多视频文件。它们中的大多数具有“.mp4”格式,如何获取存储在存档中的文件的扩展名?
我使用 php-aws-sdk 和 Laravel。我正在尝试删除硬编码的“.mp4”,当我尝试获取“$result->get('body')”时它返回一个“流”,我没有看到任何扩展名为的字段该对象中的文件。
$result = $this->client->getJobOutput([
'accountId' => config('aws.account_id'),
'jobId' => $job_id,
'vaultName' => config('aws.vault_name'),
]);
$video_file_name = '/tmp/' . $archive_name . '.mp4';
$video_file_path = public_path($video_file_name);
$fp = fopen($video_file_path, "w");
fwrite($fp, $video_source_stream);
fclose($fp);
解决方案
相反,我的意思是当我要从冰川下载文件时如何获得扩展名,我的服务器上还没有那个文件。
冰川返回给我的是:
GuzzleHttp\Psr7\Stream^ {#1155 -stream: 流资源 {@722 wrapper_type: "PHP" stream_type: "TEMP" mode: "w+b" unread_bytes: 0 seekable: true uri: "php://temp" options : [] } -size: null -seekable: true -readable: true -writable: true -uri: "php://temp" -customMetadata: [] }
我可以使用该流对象的 ->get('body') 并将其保存到文件中。但是如何找到我们要创建的文件的扩展名是什么?
$fp = fopen('/tmp/' . $archive_name . '.mp4', "w");
fwrite($fp, $result->get('body'));
fclose($fp);
推荐阅读
- c++ - 如何在具有依赖关系的 qbs 产品之间强制同步?
- android - HashMap 为空,因此我无法从 Firebase 数据库获取模拟器中显示的数据
- javascript - Autoprefixer 导致 node-sass 源映射指向错误的文件
- react-native - 来自 json GPS API 的 React Native 动态更新状态
- unity3d - AR 放置一个大小相同的物体
- mysql - mysql查询select sum where子句
- c# - C# - 你能做一组正则表达式搜索模式吗?
- jquery - GenerateIIDForListItem 返回 null
- javascript - 链接jade和javascript文件
- html - 引导按钮中的图像随背景颜色而不是按钮颜色而变化