【发布时间】:2018-11-08 04:50:26
【问题描述】:
我在 NodeJS 中编写了一个简单的文件服务器来提供带有保存到驱动器按钮的 HTML 页面。 HTML 页面在my_address:1337 提供,要保存的文件在my_address:1338 提供。单击保存到驱动器按钮后,它显示“开始下载”很长一段时间,然后显示Failed Download. XHR Error。
我认为这是因为文件是从不同的端口提供的,所以我决定对 appengine 应用程序做同样的事情。在http://sayodrive.appspot.com/index.html 提供的页面和在http://sayodrive.appspot.com/drivefile.jsp 提供的文件,我遇到了同样的问题。
然后我决定做一个本地 Java Web 应用程序:同样的问题。然后我尝试将内容配置更改为attachment(强制下载),但也没有用。
沮丧,我开始谷歌搜索并遇到this page 声称“保存到驱动器”按钮实际上不起作用。 所以我回到official Google Drive SDK page,发现他们的示例按钮也不起作用。 这是个噩梦吗?
来源:index.html
<html>
<head>
<title>Test: Save To Drive</title>
<!-- -->
<link rel="canonical" href="http://sayodrive.appspot.com">
<script src="https://apis.google.com/js/plusone.js"></script>
</head>
<body>
<p>This must be the worst HTML you have ever seen :)</p>
<div class="g-savetodrive"
data-src="//http://sayodrive.appspot.com/drivefile.jsp"
data-filename="Test Drive"
data-sitename="Sayo Saves">
</div>
</body>
</html>
来源:drivefile.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>DriveFile</title>
</head>
<body>
<%
java.io.Writer w = response.getWriter();
response.setContentType("text/plain");
w.write("If you're reading this in Drive, congrats!");
w.flush();
w.close();
%>
</body>
</html>
【问题讨论】:
-
感谢您的报告,Google 正在尽快调查此事。
-
Google 正在单独调查文档按钮。
-
你能检查你的data-src吗?
-
您的示例有效。您的示例与官方示例之间的唯一区别是 data-src 格式(官方示例中的前导
//)。
标签: google-drive-api