保存到驱动器按钮不起作用 [英] Save To Drive Button Doesn't Work
问题描述
我在NodeJS中编写了一个简单的文件服务器,通过Save To Drive按钮提供HTML页面。 HTML页面在 my_address:1337
处提供,要保存的文件在 my_address:1338
处提供。点击Save To Drive按钮后,会显示正在开始下载很长时间,然后显示 Failed Download。 XHR错误
。
我认为这是由于文件是从不同的端口提供的,所以我决定做同样的事情与一个appengine应用程序。页面位于 http://sayodrive.appspot.com/index.html ,并在<我有同样的问题。 rel =nofollow p>
然后我决定做一个本地的Java Web应用程序:同样的问题。然后,我尝试将内容处置更改为附件
(强制下载),但也无法正常工作。
沮丧的是,我开始使用谷歌搜索,并遇到这个页面,声称保存到驱动器按钮实际上并不工作。
所以我回到官方Google Drive SDK页面,发现他们的示例按钮不起作用。 这是一个糟糕的梦想吗?
SOURCE:index.html
< HTML>
< head>
< title>测试:保存到驱动器< / title>
<! - - >
< link rel =canonicalhref =http://sayodrive.appspot.com>
< script src =https://apis.google.com/js/plusone.js>< / script>
< / head>
< body>
< p>这必须是您见过的最糟糕的HTML:)< / 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 =javacontentType =text / html; charset = UTF-8
pageEncoding =UTF-8%>
<!DOCTYPE html PUBLIC - // W3C // DTD HTML 4.01 Transitional // ENhttp://www.w3.org/TR/html4/loose.dtd\">
< html>
< head>
< meta http-equiv =Content-Typecontent =text / html; charset = UTF-8>
< title> DriveFile< / title>
< / head>
< body>
<%
java.io.Writer w = response.getWriter();
response.setContentType(text / plain);
w.write(如果你正在阅读Drive,恭喜!);
w.flush();
w.close();
%>
< / body>
< / html>
原始示例不起作用,因为 Cache-Control
标头没有被服务器公开。
Access-Control-Expose-Headers:Cache-Control,Content-Encoding,Content-Range
更多文档。
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屋!