保存到驱动器按钮不起作用 [英] Save To Drive Button Doesn't Work
问题描述
我在NodeJS中编写了一个简单的文件服务器,以使用保存到驱动器"按钮来提供HTML页面.HTML页面位于 my_address:1337
,而要保存的文件位于 my_address:1338
.单击保存到驱动器"按钮后,它会长时间显示正在开始下载",然后显示失败的下载.XHR错误
.
我认为这是由于文件是从其他端口提供的,因此我决定对appengine应用程序执行相同的操作.在 http://sayodrive.appspot.com/index.html 上投放的页面,在<一个href ="http://sayodrive.appspot.com/drivefile.jsp" rel ="nofollow"> http://sayodrive.appspot.com/drivefile.jsp ,我遇到了同样的问题.>
然后,我决定做一个本地Java Web应用程序:同样的问题.然后,我尝试将内容的配置更改为 attachment
(强制下载),但也无济于事.
我很沮丧,我开始使用Google搜索,并遇到了此页面,该页面声称保存到驱动器"按钮没有实际工作.因此,我回到了 Google云端硬盘SDK的官方页面,发现他们的示例按钮不起作用也.这是一个噩梦吗?
来源:index.html
< html>< head>< title>测试:保存到云端硬盘</title><!-->< link rel ="canonical" href ="http://sayodrive.appspot.com">< script src ="https://apis.google.com/js/plusone.js"></script></head><身体>< p>这必须是您见过的最糟糕的HTML:)</p>< div class ="g-savetodrive"data-src ="//http://sayodrive.appspot.com/drivefile.jsp"data-filename =测试驱动器"data-sitename ="Sayo保存"></div></body></html>
来源:drivefile.jsp
<%@页面语言="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><元http-equiv ="Content-Type" content ="text/html; charset = UTF-8">< title> DriveFile</title></head><身体><%java.io.Writer w = response.getWriter();response.setContentType("text/plain");w.write(如果您正在云端硬盘中阅读此内容,请恭喜!");w.flush();w.close();%></body></html>
原始示例无法正常工作,因为服务器未公开 Cache-Control
标头.现在,此问题已解决.
Access-Control-Expose-Headers:缓存控制,内容编码,内容范围
文档中的更多内容.
I wrote a simple file server in NodeJS to serve a HTML page with a Save To Drive button. HTML page is served at my_address:1337
and file to be saved is served at my_address:1338
. Upon clicking the Save To Drive button, it shows "Starting Download" for a long time then displays Failed Download. XHR Error
.
I thought this was due to the fact that the file was being served from a different port so I decided to do the same with an appengine app. Page served at http://sayodrive.appspot.com/index.html and file served at http://sayodrive.appspot.com/drivefile.jsp, I got the same problem.
Then I decided to do a local Java web application: same problem. Then I tried changing the content disposition to attachment
(to force a download) but didn't work either.
Frustrated, I started Googling and came across this page that claims the Save To Drive button doesn't actually work. So I went back to the official Google Drive SDK page and discovered that their example button doesn't work too. Is this a bad dream?
SOURCE: 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>
SOURCE: 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>
The original sample was not working because the Cache-Control
header was not being exposed by the server. This is now fixed.
Access-Control-Expose-Headers: Cache-Control, Content-Encoding, Content-Range
More in the documentation.
这篇关于保存到驱动器按钮不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!