【问题标题】:Google Drive Web View returns wrong content-typeGoogle Drive Web View 返回错误的内容类型
【发布时间】:2012-11-29 21:50:17
【问题描述】:

根据这篇博文,Google Drive 应该能够提供 html:http://googleappsdeveloper.blogspot.nl/2012/11/announcing-google-drive-site-publishing.html

但在我的帐户中,我只是在<pre></pre> 之间获取我的 html 代码。

我用测试 html 文件创建了一个测试文件夹:https://googledrive.com/host/0BxVNvXP_dI5QTEstTEtmMXNkOFU/

html文件的内容:

<html>
<head>
    <title>Test 123</title>
</head>
<body>
    Test 123.
</body>
</html>

博文中的 example 具有以下 HTTP 响应标头:

HTTP/1.1 200 OK
status: 200 OK
version: HTTP/1.1
cache-control: private, max-age=315360000
content-length: 1724
content-type: text/html
date: Thu, 29 Nov 2012 12:55:22 GMT
last-modified: Tue, 06 Nov 2012 23:57:41 GMT
server: HTTP Upload Server Built on Nov 21 2012 16:10:52 (1353543052)

我的页面具有以下 HTTP 响应标头:

HTTP/1.1 200 OK
status: 200 OK
version: HTTP/1.1
cache-control: private, max-age=315360000
content-length: 96
content-type: text/plain
date: Thu, 29 Nov 2012 12:51:00 GMT
last-modified: Thu, 29 Nov 2012 12:50:28 GMT
server: HTTP Upload Server Built on Nov 21 2012 16:10:52 (1353543052)

因此区别在于content-type 标头。不知何故,我需要告诉 Google Drive 我的 html 确实是一个 html。文件。

【问题讨论】:

    标签: google-drive-api


    【解决方案1】:

    文件的 MIME 类型在上传时设置。您是否上传了带有 .txt 扩展名的文件并重命名了它?如果您删除并重新上传 HTML 文件,我敢打赌它会起作用。

    【讨论】:

    • 我是通过shiftedit.net 创建的。下载和重新上传确实修复了它。我将联系 Shiftedit 的创建者,以便他可以实现正确的 MIME 类型创建。
    • 现在固定在 shiftit,文件将在 Google Drive 中获得正确的 MIME 类型。
    猜你喜欢
    • 1970-01-01
    • 2020-11-14
    • 1970-01-01
    • 2021-04-15
    • 2017-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多