Vis*_*yas 5 icalendar android google-chrome google-calendar-api http-headers
案例 1 我在 Amazon AWS 上托管了一个日历事件 iCal .ics文件,并且该文件的 HTTP URL 集成在我的 Android 应用程序中。
当用户单击 URL 时,会显示一个带有以下选项的意图选择器:
当我选择 Google 日历时,它给了我一个错误消息“无法启动事件”
当我选择 Chrome 时,文件被下载,当用户点击下载的文件时,它给出同样的错误“无法启动事件”
以下是使用桌面 chrome http 客户端 Postman 下载文件时的响应标头
Accept-Ranges ? bytes
Content-Length ? 959
Content-Type ? application/octet-stream
Date ? Thu, 10 Mar 2016 13:45:10 GMT
ETag ? "5d48719213395a28e09e8adf01f6ce83"
Last-Modified ? Wed, 09 Mar 2016 15:24:22 GMT
Server ? AmazonS3
x-amz-id-2 ? XXXXXXXXXXXXXXXXXXXXXXXXX
x-amz-request-id ? XXXXXXXXXXXXXXXXXXX
Run Code Online (Sandbox Code Playgroud)
案例 2 为了实验,我在本地 Apache 服务器上编写了一个简单的 PHP 脚本来下载相同的文件,而不是直接从 HTTP URL 访问文件
PHP代码
<?php
$file = $_GET['file'];
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
?>
Run Code Online (Sandbox Code Playgroud)
该文件已成功下载,然后
以下是使用 PHP 脚本时的响应头
Cache-Control ? must-revalidate, post-check=0, pre-check=0
Connection ? Keep-Alive
Content-Description ? File Transfer
Content-Disposition ? attachment; filename=World_Television_Premiere_of_House_Of_Cards_March_1213_5pm_on_Zee_Cafe.ics
Content-Length ? 959
Content-Transfer-Encoding ? binary
Content-Type ? application/octet-stream
Date ? Thu, 10 Mar 2016 07:27:15 GMT
Expires ? 0
Keep-Alive ? timeout=5, max=100
Pragma ? public
Server ? Apache/2.4.7 (Ubuntu)
X-Powered-By ? PHP/5.5.9-1ubuntu4.14
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助理解为什么事件没有被保存或为案例 1 工作?
提前致谢。请帮忙。
编辑
安卓设备:Nexus 6 (6.0.1)
谷歌日历应用:5.3.6-115544951-release
在第一种情况下,您可能希望将 Content-Type 设置为文本/日历
在第二种情况下,事情确实有效,可能是因为您传递的内容处置的文件名以 .ics 结尾。因此客户端可以从扩展名推断出格式。
| 归档时间: |
|
| 查看次数: |
6685 次 |
| 最近记录: |