【发布时间】:2023-04-08 20:05:01
【问题描述】:
正如 Google Drive API 文档所说的下载文件:
https://www.googleapis.com/drive/v3/files/FILEID?alt=media%26key=API_KEY
如果我们将此链接粘贴到 Chrome 或 Safari,它将开始下载。
但问题是
- 名称改为FIELDID
- 扩展已消失
例如
我有文件 mywork.fbx 我上传到谷歌驱动器,文件 ID 是 ABCDEFG
然后我去下面的链接。
https://www.googleapis.com/drive/v3/files/ABCDEFG?alt=media%26key=MYAPIKEY
我得到了一个名为 ABCDEFG 的文件,没有扩展名
它应该是 mywork.fbx 或 anyname.fbx 而不仅仅是 ABCDEFG
试过
- 添加 &download="mywork.fbx"
- 使用 PHP header('Content-Disposition: attachment; filename="mywork.fbx"'); 文件名是 mywork.fbx 但带宽也是我的 这不仅是 Google Drive! !
$file_url = 'https://www.googleapis.com/drive/v3/files/ABCDEFG?alt=media&key=KEY';
header('Content-Disposition: attachment; filename="mywork.fbx"');
readfile($file_url);
- 查看堆栈溢出中的文章,但找不到合适的文章
【问题讨论】:
标签: google-api google-drive-api